property problems

Mike C. Fletcher mcfletch at rogers.com
Thu Nov 14 09:34:37 EST 2002


Old style class:

     class x:

New style class:

     class x(object):
     class y(x): # if x is defined with class x(object):

or

     class x(list):
     class x(str):
     class x(dict):
     ...

That is, a new-style class is a sub-class of a new-style class.  object,
list, str, and dict are convenient (and common) base-classes for
new-style classes.

HTH,
Mike

newt_e at blueyonder.co.uk wrote:

 >Mike wrote :
 >
 >
 >
 >>Okay, there's a number of things going on here:
 >>
 >>   * properties only work (properly) with new-style classes, new-style
 >>    classes derive from other new-style classes, normally "object".
 >>     Your class GlobalVars is an old-style class.  Derive from object
 >>    to prevent problems which _will_ come up later on.
 >>
 >>
 >
 >What defines my class as an old-style class? How would I turn it into 
a new class?
 >
 >
...
_______________________________________
   Mike C. Fletcher
   Designer, VR Plumber, Coder
   http://members.rogers.com/mcfletch/






More information about the Python-list mailing list