Nested scopes: design or implementation?
mmillikan at vfa.com
mmillikan at vfa.com
Wed Mar 6 08:46:20 EST 2002
Note that the <func_code> object is shared by each of the inner
<function> objects:
text = "random text"
def function():
def attribute( bindNow = text):
print bindNow
function.attribute = attribute
Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> function()
>>> function.attribute()
random text
>>> function.attribute
<function attribute at 01A7930C>
>>> function.attribute.func_code
<code object attribute at 01A79F48, file "c:\\python-YYAS0o", line 3>
>>> function()
>>> function.attribute.func_code
<code object attribute at 01A79F48, file "c:\python-YYAS0o", line 3>
>>> text = 'new random text'
>>> function()
>>> function.attribute
<function attribute at 01A450CC>
>>> function.attribute.func_code
<code object attribute at 01A79F48, file "c:\python-YYAS0o", line 3>
Mark Millikan
More information about the Python-list
mailing list