Want more features on Pastebin? Sign Up, it's FREE!
Guest

Why you shouldn't mess with __dict__

By: a guest on Jul 14th, 2011  |  syntax: None  |  size: 0.27 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data