>>> class Evil: ... __dict__ = { 'x': 2 } ... x = 3 ... >>> e = E() >>> e.x 3 >>> e.__dict__ {'x': 2} >>>
-
-
Show this thread
-
>>> class E: ... __dict__ = { 'x': 1 } ... x = 2 ... def __init__(self): ... self.x = 3 ... self.__dict__ = { 'x': 4 } ... >>> e = E() >>> e.x 3 >>> e.__dict__['x'] 4 >>> E.x 2 >>> E.__dict__['x'] 2 >>> del e.__dict__ >>> e.__dict__['x'] 1
Show this thread -
Ok. Enough frivolity for now. BTW: You can't spell "Enterprise" without "E".
Show this thread
End of conversation
New conversation -
-
-
Thought you said classes were good
-
Classes are fine. It’s the dicts.
-
You're right. It's always the dicts.
-
Freaking dicts. Shakes head.
End of conversation
New conversation -
-
-
Bug in CPython? You can't do this to an instance directly. Also the documentation says that "__dict__" is read-only: https://docs.python.org/3/library/stdtypes.html#special-attributes …pic.twitter.com/UglmQz6fOS
-
That’s not the dict you’re looking for.
End of conversation
New conversation -
-
-
Can we call this pattern the "Edict of Beazley"?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
>>> Evil.__dict__ {'__dict__': None, '__module__': '__main__', '__doc__': None, '__init__': <function __init__ at 0x...>} '__dict__' key inside __dict__ attribute...
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.