representation of unbound methods - strange behaviour

Stefan Franke spamfranke at bigfoot.de
Wed Aug 18 19:46:55 CEST 1999


Why does this happen:

Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> class A: pass
>>> def f(): pass
>>> A.f = f
>>> A.g = f
>>> A.f
<unbound method A.f>
>>> A.g
<unbound method A.f>
                ^^^

This is independent of the assignment order of f and g:

>>> class A: pass
>>> def f(): pass
>>> A.g = f        # swapped
>>> A.f = f        # order
>>> A.f
<unbound method A.f>
>>> A.g
<unbound method A.f>

Method caching?
Stefan





More information about the Python-list mailing list