Maybe it's a mod_python issue I'm hitting?
manus at bullfrog-tech.com
Thu Aug 29 22:24:03 CEST 2002
It seems that all my code of the form:
still DOES work fine under 2.2. (Yay! Whew!)
The one thing that STOPPED working reliably is this:
locals()[varName] = someValue
My initial thought was that PEP 227 had made locals() read-only, hence my post
at the start of this thread. However, I soon realized that this line worked
under 2.2 while it sat at global scope. The line started failing when I put it
into a function (specifically, a handler() function, as part of a port to a
I then figured the issue still had to do with scope nests, although I did think
it pretty inconsistent and screwy that the same code would work fine at global
scope but not when you stuck it into a function. But then....
I wrote a simple test function:
for var in varDict: # or these two lines could
locals()[var] = varDict[var] # be locals().update(varDict)
When this same code snippet is in the handler() function for mod_python,
for var in util.FieldStorage(req).list:
locals()[var.name] = urllib.unquote(var.value)
for var in form:
print var, form[var], '<br>' # <-- yes, it prints them all
locals()[var] = form[var]
print locals() # <--- but this one gets some SUBSET of the variables!!
That is, SOME of them make it and other ones don't.
The assignment doesn't except, but it also doesn't assign!
In short, I had initially thought this was caused by PEP 227; now I am not so
More information about the Python-list