F
Florian Lindner
Hello,
I have a:
class C:
def __init__(self):
d = dict_like_object_created_somewhere_else()
def some_other_methods(self):
pass
class C should behave like a it was the dict d. So I could do:
c = C()
print c["key"]
print len(c)
but also
c.some_other_method()
How can I achieve that? Do I need to define all methods like
__getitem__, __len__, ... (what else?) to access the inner dict or is
there something more slick?
Thanks,
Florian
I have a:
class C:
def __init__(self):
d = dict_like_object_created_somewhere_else()
def some_other_methods(self):
pass
class C should behave like a it was the dict d. So I could do:
c = C()
print c["key"]
print len(c)
but also
c.some_other_method()
How can I achieve that? Do I need to define all methods like
__getitem__, __len__, ... (what else?) to access the inner dict or is
there something more slick?
Thanks,
Florian