Some questions are probably popping up in your head at this point. Or maybe they aren't, but I'll answer them anyway:
Q: | How does Python really create a new object? |
A: | Internally, when Python creates a new object, it always
uses a type and creates an instance of that object. Specifically it
uses the |
Q: | When using instantiation, I specify the type, but how does Python know which type to use when I use subclassing? |
A: | It looks at the base class that you specified, and uses
its type as the type for the new object. In the example Example 2.4, “Creating new objects by subclassing” , A little thought reveals that under most circumstances, any
subclasses of |
Advanced Material Ahead
Advanced discussion ahead, tread with caution, or jump straight to the next section.