class, dict, self, init, args ?
Posted
by kame
on Stack Overflow
See other posts from Stack Overflow
or by kame
Published on 2010-04-14T22:22:39Z
Indexed on
2010/04/14
22:53 UTC
Read the original article
Hit count: 463
python
class attrdict(dict):
def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)
self.__dict__ = self
a = attrdict(x=1, y=2)
print a.x, a.y
b = attrdict()
b.x, b.y = 1, 2
print b.x, b.y
Could somebody explain the first four lines in words? I read about classes and methods. But here it seems very confusing.
© Stack Overflow or respective owner