Re: Metaclasses and class variables

2005-08-04 Thread Bengt Richter
On Thu, 4 Aug 2005 17:53:28 +0200, Jan-Ole Esleben <[EMAIL PROTECTED]> wrote: >Thanks! It's a bit icky, yes, but I've been so wrapped up in >complicated thinking that I didn't see this. It's actually quite an >OK solution (I need it because I have an internal representation for >method interfaces

Re: Metaclasses and class variables

2005-08-04 Thread Jan-Ole Esleben
Thanks! It's a bit icky, yes, but I've been so wrapped up in complicated thinking that I didn't see this. It's actually quite an OK solution (I need it because I have an internal representation for method interfaces that needs to be saved somewhere without the user having to worry about it, and wi

Re: Metaclasses and class variables

2005-08-04 Thread Mike C. Fletcher
Jan-Ole Esleben wrote: >Yes, that works, but it is unfortunately not an option (at least not a >good one). > >Is there no way to create a class variable that exists during >definition of the class? (I cannot imagine there isn't, since >technically it's possible and manually it can be done...) > >O

Re: Metaclasses and class variables

2005-08-04 Thread Jan-Ole Esleben
Yes, that works, but it is unfortunately not an option (at least not a good one). Is there no way to create a class variable that exists during definition of the class? (I cannot imagine there isn't, since technically it's possible and manually it can be done...) Ole > classvar is defined AFTER

Re: Metaclasses and class variables

2005-08-04 Thread Kent Johnson
Christopher Subich wrote: > Jan-Ole Esleben wrote: > >> class Meta(type): >> def __new__(cls, name, bases, d): >> d['classvar'] = [] >> return type.__new__(cls, name, bases, d) > > > The problem is that __new__ is called upon object construction, not > class definition, but you're try

Re: Metaclasses and class variables

2005-08-04 Thread Thomas Heller
Jan-Ole Esleben <[EMAIL PROTECTED]> writes: > Hi! > > I am new to this list, and maybe this is a stupid question, but I > can't seem to find _any_ kind of answer anywhere. > > What I want to do is the following: > I want to insert a class variable into a class upon definition and > actually use it

Re: Metaclasses and class variables

2005-08-04 Thread Jan-Ole Esleben
I thought __new__ was called upon construction of the _class_ object that "Meta" is the type of. Then it would be available at the time of the definition of my class. Or am I mistaken? Ole 2005/8/4, Christopher Subich <[EMAIL PROTECTED]>: > Jan-Ole Esleben wrote: > > class Meta(type): > > def _

Re: Metaclasses and class variables

2005-08-04 Thread Christopher Subich
Jan-Ole Esleben wrote: > class Meta(type): > def __new__(cls, name, bases, d): > d['classvar'] = [] > return type.__new__(cls, name, bases, d) The problem is that __new__ is called upon object construction, not class definition, but you're trying to set the class variables at definitio

Metaclasses and class variables

2005-08-04 Thread Jan-Ole Esleben
Hi! I am new to this list, and maybe this is a stupid question, but I can't seem to find _any_ kind of answer anywhere. What I want to do is the following: I want to insert a class variable into a class upon definition and actually use it during definition. Manually, that is possible, e.g.: cla