Re: class static variables and __dict__

2008-02-17 Thread Arnaud Delobelle
On Feb 16, 11:59 pm, Zack <[EMAIL PROTECTED]> wrote: > Zack wrote: > > Diez B. Roggisch wrote: > >> Zack schrieb: > >>> If I have a class static variable it doesn't show up in the __dict__ > >>> of an instance of that class. > > >>> class C: > >>>    n = 4 > > >>> x = C() > >>> print C.__dict__ > >

Re: class static variables and __dict__

2008-02-16 Thread 7stud
On Feb 16, 5:03 pm, Zack <[EMAIL PROTECTED]> wrote: > Dustan wrote: > > On Feb 16, 4:40 pm, Zack <[EMAIL PROTECTED]> wrote: > >> what method can you use on x to find all available > >> attributes for that class? > > class Foo(object): > >    bar = "hello, world!" > >    def __init__(self, baz)

Re: class static variables and __dict__

2008-02-16 Thread Zack
Dustan wrote: > On Feb 16, 5:59 pm, Zack <[EMAIL PROTECTED]> wrote: >> Zack wrote: >>> Diez B. Roggisch wrote: Zack schrieb: > If I have a class static variable it doesn't show up in the __dict__ > of an instance of that class. > class C: >n = 4 > x = C() > print C.

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 5:59 pm, Zack <[EMAIL PROTECTED]> wrote: > Zack wrote: > > Diez B. Roggisch wrote: > >> Zack schrieb: > >>> If I have a class static variable it doesn't show up in the __dict__ > >>> of an instance of that class. > > >>> class C: > >>>n = 4 > > >>> x = C() > >>> print C.__dict__ > >>

Re: class static variables and __dict__

2008-02-16 Thread Zack
Dustan wrote: > On Feb 16, 4:40 pm, Zack <[EMAIL PROTECTED]> wrote: >> what method can you use on x to find all available >> attributes for that class? > class Foo(object): > bar = "hello, world!" > def __init__(self, baz): > self.baz = baz > x = Foo(42) > >>>

Re: class static variables and __dict__

2008-02-16 Thread Zack
Zack wrote: > Diez B. Roggisch wrote: >> Zack schrieb: >>> If I have a class static variable it doesn't show up in the __dict__ >>> of an instance of that class. >>> >>> class C: >>>n = 4 >>> >>> x = C() >>> print C.__dict__ >>> {'__module__': '__main__', '__doc__': None, 'n': 4} >>> print x._

Re: class static variables and __dict__

2008-02-16 Thread Dustan
On Feb 16, 4:40 pm, Zack <[EMAIL PROTECTED]> wrote: > what method can you use on x to find all available > attributes for that class? >>> class Foo(object): bar = "hello, world!" def __init__(self, baz): self.baz = baz >>> x = Foo(42) >>> x.__dict__.keys() # Does

Re: class static variables and __dict__

2008-02-16 Thread Zack
Diez B. Roggisch wrote: > Zack schrieb: >> If I have a class static variable it doesn't show up in the __dict__ >> of an instance of that class. >> >> class C: >>n = 4 >> >> x = C() >> print C.__dict__ >> {'__module__': '__main__', '__doc__': None, 'n': 4} >> print x.__dict__ >> {} >> >> This

Re: class static variables and __dict__

2008-02-16 Thread Diez B. Roggisch
Zack schrieb: > If I have a class static variable it doesn't show up in the __dict__ of > an instance of that class. > > class C: >n = 4 > > x = C() > print C.__dict__ > {'__module__': '__main__', '__doc__': None, 'n': 4} > print x.__dict__ > {} > > This behavior makes sense to me as n is n

class static variables and __dict__

2008-02-16 Thread Zack
If I have a class static variable it doesn't show up in the __dict__ of an instance of that class. class C: n = 4 x = C() print C.__dict__ {'__module__': '__main__', '__doc__': None, 'n': 4} print x.__dict__ {} This behavior makes sense to me as n is not encapsulated in x's namespace but w