Re: classmethods, class variables and subclassing

2005-10-21 Thread Andrew Jaffe
Steven Bethard wrote: > Andrew Jaffe wrote: > > I'm not sure if I understand your goal here, but you can get different > behavior using super(). > > py> class sup(object): > ... cvar1 = None > ... cvar2 = None > ... @classmethod > ... def setcvar1(cls, val): > ... cls.cva

Re: classmethods, class variables and subclassing

2005-10-21 Thread Ron Adam
Andrew Jaffe wrote: > Hi, > > I have a class with various class-level variables which are used to > store global state information for all instances of a class. These are > set by a classmethod as in the following (in reality the setcvar method > is more complicated than this!): > > class sup

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steven Bethard
Andrew Jaffe wrote: > Hi, > > I have a class with various class-level variables which are used to > store global state information for all instances of a class. These are > set by a classmethod as in the following (in reality the setcvar method > is more complicated than this!): > > class sup(

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steve Holden
Steve Holden wrote: [...] > > I think so. It's not normal adive, but it sounds like a metaclass might > be what you need here. > ^adive^advice^ spell-me-own-name-wrong-next-ly y'rs - evest -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steve Holden
Andrew Jaffe wrote: > Steve Holden wrote: > >>Andrew Jaffe wrote: >> >>>Steve Holden wrote: >>> Andrew Jaffe wrote: >The problem is that I actually do want to call these methods on the >class itself, before I've made any instances. > Except you could use staticm

Re: classmethods, class variables and subclassing

2005-10-21 Thread Andrew Jaffe
Steve Holden wrote: > Andrew Jaffe wrote: >> Steve Holden wrote: >>> Andrew Jaffe wrote: >>> The problem is that I actually do want to call these methods on the class itself, before I've made any instances. >>> Except you could use staticmethods with an explicit class argument ... >

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steve Holden
Andrew Jaffe wrote: > Steve Holden wrote: > >>Andrew Jaffe wrote: >> >> >>>The problem is that I actually do want to call these methods on the >>>class itself, before I've made any instances. >>> >> >>Except you could use staticmethods with an explicit class argument ... > > > Steve, > > Yep,

Re: classmethods, class variables and subclassing

2005-10-21 Thread Andrew Jaffe
Steve Holden wrote: > Andrew Jaffe wrote: > >>The problem is that I actually do want to call these methods on the >>class itself, before I've made any instances. >> > Except you could use staticmethods with an explicit class argument ... Steve, Yep, that would work! Thanks. But it does seem li

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steve Holden
Andrew Jaffe wrote: >>Andrew Jaffe wrote: [...] > > The problem is that I actually do want to call these methods on the > class itself, before I've made any instances. > Except you could use staticmethods with an explicit class argument ... regards Steve -- Steve Holden +44 150 684 725

Re: classmethods, class variables and subclassing

2005-10-21 Thread Steve Holden
Andrew Jaffe wrote: >>Andrew Jaffe wrote: >> >> >>>Hi, >>> >>>I have a class with various class-level variables which are used to >>>store global state information for all instances of a class. These are >>>set by a classmethod as in the following >>> >>>class sup(object): >>> cvar1 = None >>

Re: classmethods, class variables and subclassing

2005-10-20 Thread Andrew Jaffe
> Andrew Jaffe wrote: > >> Hi, >> >> I have a class with various class-level variables which are used to >> store global state information for all instances of a class. These are >> set by a classmethod as in the following >> >> class sup(object): >> cvar1 = None >> cvar2 = None >> >>

Re: classmethods, class variables and subclassing

2005-10-20 Thread Steve Holden
Andrew Jaffe wrote: > Hi, > > I have a class with various class-level variables which are used to > store global state information for all instances of a class. These are > set by a classmethod as in the following (in reality the setcvar method > is more complicated than this!): > > class sup(

classmethods, class variables and subclassing

2005-10-20 Thread Andrew Jaffe
Hi, I have a class with various class-level variables which are used to store global state information for all instances of a class. These are set by a classmethod as in the following (in reality the setcvar method is more complicated than this!): class sup(object): cvar1 = None cvar