Re: Accessing class variable at class creation time

2005-09-24 Thread Jan-Ole Esleben
That doesn't really give him a way of using the class variable inside a method. Ole 2005/9/24, Benji York <[EMAIL PROTECTED]>: > Carlos wrote: > > Hi! > > > > class A: > > X = 2 > > def F(): > > print A.X > > F() > > > > The above fails because the name A is not > > yet at global scope

Re: Accessing class variable at class creation time

2005-09-23 Thread Jan-Ole Esleben
You could use self.__class__.X HTH, Ole 23 Sep 2005 14:01:21 -0700, Carlos <[EMAIL PROTECTED]>: > Hi! > > class A: > X = 2 > def F(): > print A.X > F() > > The above fails because the name A is not > yet at global scope when the reference A.X > is reached. Is there any way to refer to

Re: Why is this?

2005-08-10 Thread Jan-Ole Esleben
For the sake of completeness (I didn't copy this message to the list): > I have a problem with initialization. > >>> a, b = [[]]*2 > >>> a.append(1) > >>> b > [1] > > Why is this? Why does not this behave like the below: You create a single list (inside your brachets) and duplicate a reference to

Metaclasses and new-style classes

2005-08-07 Thread Jan-Ole Esleben
Hi! I've just posted a question about metaclasses in ZOPE on the ZOPE list, and one of the replies said that metaclasses (at least "painless" metaclasses) cannot be used without new-style classes (or rather, that they don't work where you cannot explicitly use new-style classes). I haven't so far

Re: Metaclasses and class variables

2005-08-04 Thread Jan-Ole Esleben
. Ole 2005/8/4, Mike C. Fletcher <[EMAIL PROTECTED]>: > 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

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 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: > > cl

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