Is vars() meant to include globals?

Alex Martelli aleaxit at yahoo.com
Sat Sep 16 09:34:38 CEST 2000


"Opinderjit" <bhellao at my-deja.com> wrote in message
news:8pur74$jfb$1 at nnrp1.deja.com...
>
> Where does the "classvar" variable go? It doesn't seem to be contained
> in vars(), locals() or globals().
    [snip]
> > class SomeClass:
> >     classvar = 3


Remember that vars() takes an argument -- the object whose variables
you want!  Here, you want the variables of the class object:

>>> class SomeClass:
 classvar = 3

>>> vars(SomeClass)
{'classvar': 3, '__module__': '__main__', '__doc__': None}
>>>


Alex






More information about the Python-list mailing list