Scopes and exceptions
Magnus Heino
magnus.heino at rivermen.se
Fri Dec 15 03:33:46 EST 2000
Could someone please explain this to me:
[magnus at daysleeper magnus]$ cat e.py
a = 'test'
b = 'test'
print 'a = %s' % id(a)
print 'b = %s' % id(b)
def func():
print "'test' = %s" % id('test')
func()
try:
test, '%s' % (a,)
except NameError, e:
print 'e = %s' % id(e)
print 'a = %s' % id(a)
print 'b = %s' % id(b)
print "'test' = %s" % id('test')
[magnus at daysleeper magnus]$ python e.py
a = 136227368
b = 136227368
'test' = 136227368
e = 135997204
a = 136227368
b = 136227368
'test' = 136227368
[magnus at daysleeper magnus]$
/Magnus
More information about the Python-list
mailing list