Bruno Desthuilliers wrote:
(snip)
Joel Juvenal Rivera Rivera wrote:
Hi i was playing around with my code the i realize of this
###################
_uno__a = 1
class uno():
    __a = 2
    def __init__(self):
        print __a
uno()
###################
and prints 1
<snip>
I beg to disagree. The problem (well... what I think is a problem, actually) IS that name mangling is applied to a method *local* variable.


It is not a local variable, because there's no assignment within that same method. That decision happens at compile time of the definition. Once it's not a local, then it needs to get mangled, per the rules for double-underscore.

Try adding a __a = 49 before or after the line in question. Either one will change the behavior (and/or the error message) to indicate that it's a local.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to