class Rec(object):
pass
rec = Rec()
print(rec.__class__)
print(Rec.__bases__)
<class '__main__.Rec'> (<class 'object'>,)
Classes are objects in their own right, even without instance
class Rec(object):
pass
print(Rec)
<class '__main__.Rec'>
Assignments to attributes of self in methods make per-instance attribues
Methods named with double underscores(__x__
)
x.__init__
is often called manually to trigger initialization in a superclassClasses may override most built-in type operations
No defaults for operator overloading methods
Not are required
New-style classes (detail in next chapter) have some defaults, but not for commom operations
It's an optinal feature.
Used primarily by people developing tools for other Python programmers, not by application developers
Overloaded operators should work the same way that built-in operator