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
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
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
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
.
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
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
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
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