Can somebody give me an explanation what happened here (or point me to
some docs)?

Code:

HMMM = None

def w(fn):
    print 'fn:', id(fn)
    HMMM = fn
    print 'HMMM:', id(HMMM)
    def wrapper(*v, **kw):
        fn(*v, **kw)
    wrapper.i = fn
    print 'wrapper:', id(wrapper)
    return wrapper

class A:
    @w
    def __init__(self): pass

print 'A.__init__:', id(A.__init__)
print 'A.__init__.i:', id(A.__init__.i)
print 'HMMM:', id(HMMM)



Output:

fn: 10404208
HMMM: 10404208
wrapper: 10404272
A.__init__: 10376136
A.__init__.i: 10404208
HMMM: 505264624



Why did HMMM changed his id?!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to