building embedded classes as in C/C++

Fred L. Drake, Jr. fdrake at
Wed Aug 4 13:45:56 EDT 1999

Andy Beall writes:
 > Here, 'p' does not seem to be class-wide while 'pos' and 'ang' are.  Why
 > the discrepancy?

  The 'p' set in the class statement is class-wide.  Setting 'p' on an 
instance creates a new instance-specific binding for 'p', which is
retrieved on subsequent attribute accesses since it overrides the
class-wide value.  If you accessed it as Object.p, the original value
would still be available.
  This is a situation where the "binding" and "namespaces" terminology
is pretty important and makes it easier to understand.  There really
aren't variables in the C/C++/lots-of-others sense. Sections 9.1 and
9.2 in the tutorial may be worth reviewing here:


Fred L. Drake, Jr.	     <fdrake at>
Corporation for National Research Initiatives

More information about the Python-list mailing list