A little bit of live code to define a function called foo and assign it to a variable and pass it around as an argument.
Explain new style classes in python 2 and how python 3 classes inherit from object implicitly
We call type to determine the type(data type) of an object
Explain how we can use type to create new classes
Python 2 new style classes
Python 3 syntax
Explain how we can use type to determine the data type or class of a python object for example call type on the sys module
Type is the default meta class used to create our classes
When u create a class, that class is an instance of type at runtime.Class Foo: passFoo.__class__
This is the signature of the type meta class constructor.
Calling type on the Foo class will return type
__new__() should be overidden when you want to control the creation of the object which happens to be the class__init__() should be overidden when you want to control initiailization of the object after it has been created.__call__() is called after class creation, when the already created class is called to create instances
_ _new_ _ is called to create the class while _ _init_ _ is called after the class has been created to initialize the class
Demonstrate inheriting from the bool class. Create a meta class to create a final
Class type on class Foo and Foo.__class__
I think essentially the rule is that the metaclass of the derived class must a subclass of all metaclasses of the bases.
Python Meta Classes
Software Developer at ThoughtWorks