This appendix briefly summarizes
some of the differences between Python and C++ classes.
class system can be thought of as a
subset of C++’s. Although the comparison to Modula 3 may be
closer, C++ is the dominant OOP language today. But in Python, things
are intentionally simpler -- classes are simply
objects with attached
attributes that may have links to other class
objects. They support generation of multiple instances, customization
by attribute inheritance, and operator overloading, but the object
model in Python is comparatively uncluttered. Here are some specific
differences between Python and
There is no
real distinction between data members and methods in Python; both
simply designate named attributes of instances
or classes, bound to functions or other kinds of objects. Attributes
are names attached to objects, and accessed by qualification:
object.attribute. Methods are merely class
attributes assigned to functions normally created with nested
def statements; members are just attribute names
assigned to other kinds of objects.
create class objects and assign them to a name.
Statements that assign names within a
statement generate class attributes, and classes inherit attributes
from all other classes listed in their
statement header line (multiple inheritance is supported; this is
discussed in a moment).
Calling a class object as ...