[New-bugs-announce] [issue5197] vars() assignment fails silently when assignments made later
pest
report at bugs.python.org
Tue Feb 10 06:14:43 CET 2009
New submission from pest <luke at asterisk.co.nz>:
Assignments to vars() behave incorrectly if those variables are use
later on in a function.
For example, try this:
======
#!/usr/bin/python
def zz():
for i in [1,2,3]:
for j in [4,5,6]:
vars()['fw_%s_%s' % (j,i)] = 'test %s %s' % (j, i)
print vars()['fw_%s_%s' % (j,i)]
fw_4_2 = 'zz'
print fw_4_2
zz()
======
The assignments work fine up till 4_2. At 4_2, the assignment apparently
fails silently, and the print raises a keyError exception.
----------
components: None
messages: 81530
nosy: pest
severity: normal
status: open
title: vars() assignment fails silently when assignments made later
type: behavior
versions: Python 2.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5197>
_______________________________________
More information about the New-bugs-announce
mailing list