Wackness

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Hawthorne

    Wackness

    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
Working...