[New-bugs-announce] [issue11974] Class definition gotcha.. should this be documented somewhere?
report at bugs.python.org
Sun May 1 20:34:49 CEST 2011
New submission from Cal Leeming <cal.leeming at simplicitymedialtd.co.uk>:
So, when you create a class like this:
children = 
The 'children' object essentially becomes shared across all instances of Obj. To get around this, you have to use:
children = None
children = 
I have attached proof of concept code which can trigger this bug. Although I have almost 8 years of experience with Python, this is the first time I have actually noticed this, however, I am sure that similar things have happened in the past, and I just didn't investigate it enough to realise what was going on.
Although this isn't a bug, it is likely that other advanced developers may also not know about, or have been caught out by this little gotcha. So, perhaps it might be worth documenting it somewhere?
Let me know your thoughts.
components: Interpreter Core
title: Class definition gotcha.. should this be documented somewhere?
type: feature request
versions: Python 2.7
Added file: http://bugs.python.org/file21848/obj.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce