In [1]:
class NameSpace():
pass
In [2]:
foo = NameSpace()
foo
Out[2]:
In [3]:
def show_names(thing):
return [name for name in dir(thing) if not name.startswith('__')]
In [4]:
show_names(foo)
Out[4]:
In [5]:
foo.hello = 'world'
In [6]:
foo.bar = 3.1415926
In [7]:
show_names(foo)
Out[7]:
In [8]:
getattr(foo, 'hello')
Out[8]:
In [9]:
getattr(foo, 'bar')
Out[9]:
In [10]:
getattr(foo, 'world')