This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pest
Recipients pest
Date 2009-02-10.05:14:40
SpamBayes Score 7.20277e-06
Marked as misclassified No
Message-id <1234242883.43.0.910584647004.issue5197@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-02-10 05:14:43pestsetrecipients: + pest
2009-02-10 05:14:43pestsetmessageid: <1234242883.43.0.910584647004.issue5197@psf.upfronthosting.co.za>
2009-02-10 05:14:41pestlinkissue5197 messages
2009-02-10 05:14:41pestcreate