Everything Is An Object
Explore Python's core concept that everything is an object. Understand how functions, modules, classes, and their instances can be treated as first-class objects with attributes and methods, enabling flexible and powerful programming techniques.
We'll cover the following...
In case you missed it, I just said that Python functions have attributes, and that those attributes are available at runtime. A function, like everything else in Python, is an object.
Run the interactive Python shell and follow along:
① The first line imports the humansize program as a module — a chunk of code that you can use interactively, or from a larger Python program. Once you import a module, you can reference any of its public functions, classes, or attributes. Modules can do this to access functionality in other modules, and you can do it in the Python interactive shell too. This is ...