Does Python have Class methods

David Bolen db3l at fitlinxx.com
Thu May 10 17:01:53 EDT 2001


costas at meezon.com (Costas Menico) writes:

> I guess a similar concept would apply to class variables? Although I
> was under the impression that anything defined in a class outside of a
> method, is considered a class variable. Of course I tried it but does
> not work.

Can you describe what you wanted to happen that didn't?  It is true
that any definitions outside of a method exist at the class level, and
can be accessed either directly through the class, or indirectly as an
instance reference (e.g., Python proceeds up the inheritance tree just
as it does for methods).  And there is only one such definition at the
class level so all instances see the same value - although if an
instance is using an instance reference (e.g., self.xxx) then it could
be blocked from the class value if it has locally defined the same
name or some superclass has.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list