Wackness

Brian Hawthorne brian.lee.hawthorne at gmail.com
Tue Aug 12 23:19:10 EDT 2008


p1 = property(lambda self: self.__x)

class Foo (object):
    p1 = p1
    p2 = property(lambda self: self.__x)

    def __init__(self):
        self.__x = 10

f = Foo()

print f.p2
print f.p1

#-------------------------------------------------------

Expecting to see:

10
10

?
Think again!

Ouch, just got bit.
But I guess the name mangling has to occur at compile (to bytecode) time?

Cheers,
Brian Hawthorne



More information about the Python-list mailing list