modifying vars() dictionary?

Lance E Sloan lsloan at umich.edu
Wed May 16 13:18:04 EDT 2001


In the documentation, it says about vars():

    The returned dictionary should not be modified: the effects on
    the corresponding symbol table are undefined.

Why are the effects undefined?  Why doesn't it always work to set
a value for variable 'x' by assigning that value to the 'x' element
of the dictionary from vars()?

I've noticed that sometimes it works and sometimes it doesn't.  In my
small example it worked, but a colleague who asked me about this
couldn't get it to work in a larger program.  I assume that I'm just
lucky mine worked and that his problem may have something to do with
the size of the symbol table or the kinds of objects in it.

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Perl & Python CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"




More information about the Python-list mailing list