Skip to main content
10 events
when toggle format what by license comment
Dec 11, 2016 at 3:08 history edited Mike Müller CC BY-SA 3.0
Make it shorter.
Dec 11, 2016 at 2:57 comment added Mike Müller @MaxB I added a version that does not change locals().
Dec 11, 2016 at 2:38 history edited Mike Müller CC BY-SA 3.0
Add version without changing `locals()`.
Dec 11, 2016 at 2:32 comment added MWB Quote: "The contents of this dictionary should not be modified"
Dec 11, 2016 at 2:30 comment added MWB Right, the reader expects it to affect the local variables, but it may or may not, depending on a number of circumstances. The point is that it's UB.
Dec 11, 2016 at 2:28 comment added Mike Müller @MaxB From the docs you cite: ... changes may not affect the values of local and free variables used by the interpreter. self is still available in __init__ .
Dec 11, 2016 at 1:27 comment added MWB docs.python.org/2/library/functions.html#locals locals() should not be modified (it may affect the interpreter, in your case, removing self from the calling function's scope)
Feb 16, 2016 at 2:11 audit Low quality answers
Feb 16, 2016 at 2:11
Feb 6, 2016 at 14:37 history edited Mike Müller CC BY-SA 3.0
Typo fix.
Feb 6, 2016 at 9:59 history answered Mike Müller CC BY-SA 3.0