class static variables and __dict__

Dustan DustanGroups at
Sun Feb 17 00:52:43 CET 2008

On Feb 16, 4:40 pm, Zack <gol... at> 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 not include bar

>>> dir(x) # Includes bar plus some methods
['__class__', '__delattr__', '__dict__', '__doc__',
'__getattribute__', '__hash__', '__init__', '__module__', '__new__',
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__',
'__weakref__', 'bar', 'baz']

More information about the Python-list mailing list