In this chapter, we have begun our journey into OOP. OOP makes code more reusable; it makes it easier to design software; it makes code easier to test, debug, and maintain; and it adds a form of security to the data in an application. The behaviors of an object are known as methods, and you can add a method to a class by defining a function inside it. To be bound to your objects, this function needs to take in the argument self. We also covered class attributes and class methods in detail. We also took a look at encapsulation and the keywords that enable information hiding in Python. Information hiding is used to abstract away irrelevant details about the class from users. This chapter also covered inheritance in detail. We saw how to have a derived class inherit from a single base class, as well as multiple base classes. We also saw how to override methods: specifically, the __init__(), __str__(), and __del__() methods. This chapter completes our journey into object-oriented programming...
Python Fundamentals
By :
Python Fundamentals
By:
Overview of this book
After a brief history of Python and key differences between Python 2 and Python 3, you'll understand how Python has been used in applications such as YouTube and Google App Engine. As you work with the language, you'll learn about control statements, delve into controlling program flow and gradually work on more structured programs via functions.
As you settle into the Python ecosystem, you'll learn about data structures and study ways to correctly store and represent information. By working through specific examples, you'll learn how Python implements object-oriented programming (OOP) concepts of abstraction, encapsulation of data, inheritance, and polymorphism. You'll be given an overview of how imports, modules, and packages work in Python, how you can handle errors to prevent apps from crashing, as well as file manipulation.
By the end of this book, you'll have built up an impressive portfolio of projects and armed yourself with the skills you need to tackle Python projects in the real world.
Table of Contents (12 chapters)
Python Fundamentals
Preface
Free Chapter
Introducing Python
Data Types
Control Statements
Functions
Lists and Tuples
Dictionaries and Sets
Object-Oriented Programming
Modules, Packages, and File Operations
Error Handling
Appendix A
Customer Reviews