Advertisement
Guest User

Why you shouldn't mess with __dict__

a guest
Jul 14th, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. class A(object):
  2. def __init__(self, **kwargs):
  3. self._b ='Default'
  4. self.__dict__.update(kwargs)
  5.  
  6. @property
  7. def b(self):
  8. return self._b
  9.  
  10. @b.setter
  11. def b(self, value):
  12. self._b = value
  13.  
  14. a = A(b=1, c=2)
  15. print a.b, a.c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement