Module 4: Object Oriented Programming¶
In this module, we will come to see that Python is an object-oriented language. That is, the language is all about defining different types of objects that encapsulate data, and that possess functions that permit users to access and manipulate this data. Our tour through the essentials of Python and the essentials of NumPy brought us into contact with various types of objects, such as the
dict, and the
numpy.ndarray, to name a few. We have seen that these different types of objects have starkly different functionality from one another. We will study the syntax and constructs for creating and interacting with objects in Python. Ultimately, will find our skill sets as Python-users much fuller and more sophisticated having understood object-oriented programming in Python.
We being this module by establishing some key terminology for discussing object-oriented programming, drawing attention to the important fact that the terms ‘class’ and ‘type’ mean the same thing in modern Python. Next, we study the syntax for defining a class, and take time to distinguish between the resulting class object and the subsequent class instances that can then be created. Having defined our first custom class of object, we then study the syntax for defining class-methods, which permits us add customized functionality to our class. Further, we will introduce ourselves to Python’s reserved special methods, which empower us to fully interface our class with the Python’s protocols for behaving like a sequence, an iterable, a function, etc. We conclude this module with a brief discussion of the concept of inheritance, which is a mechanism by which a new class can inherit attributes from an existing class.
- Introduction to Object Oriented Programming
- Defining a New Class of Object
- Instances of a Class
- A Brief Summary of Terms and Concepts
- Applications of Object Oriented Programming
- Special Methods