Final Words on Classes
Classes and instances are all built using dictionaries
Take a look at the __dict__ attribute
a = Account(100) print a.__dict__ # Modify an object through it's dictionary a.__dict__['foo'] = 78
Just about everything revolves around dictionary lookup.
Example: attribute lookup, obj.
name
Look for
name
in the instance dictionary for
obj
.
Look for
name
in the class dictionary.
Look for
name
in dictionaries for base-classes.
Separation of types and classes is a topic of debate
There is a move to unify types and classes.
Specifically, built in types would become more class-like and classes would define types.
This is not yet the case however.
<<<
O'Reilly OSCON 2000, Introduction to Python, Slide 102
July 17, 2000, beazley@cs.uchicago.edu
>>>