This chapter took us from being users of classes to being creators of classes. We saw how to initialize newly created instances using the init () special method, and how to implement many of the other special methods so that our custom data types (classes) can behave just like Python's built-in classes. We also learned how to create both ordinary methods and static methods, and how to store and access both per-instance and static data.
We reviewed two complete examples. The Length class, a numeric data type, and the OrderedDict class, a collection class. We also made use of much of the knowledge gained from the previous chapters, including some of Python's advanced features, such as list comprehensions and generator methods.
This chapter also showned how to do both single and multiple inheritance, and gave an example of how to create a simple interface class. We learned more about using isinstance() for type testing, and about hasattr() and duck typing.
We concluded the chapter with an overview of how Python modules and multifile applications work. We also looked at the doctest module and saw how easy it is to create unit tests that look like examples in our docstrings.
We now know the Python language fundamentals. We can create variables, use collections, and create our own data types and collection types. We can branch, loop, call functions and methods, and raise and handle exceptions. Clearly, there is a lot more to learn, but we can cover everything else we require as the need arises. We are now ready to start GUI application programming, a topic that begins in the next chapter and which occupies the rest of the book.
Was this article helpful?
The main focus of this report is to show how to get involved in video marketing on the run, how to rank quickly on YouTube and Google using FREE semi-automatic tools and services. QUICKLY AND FREE. I will show methods and techniques I use to rank my videos, as well as free resources and tools to make video clips, to get backlinks and free traffic.