Replacement for locals() ???
Harald Armin Massa
haraldarminmassa at gmail.com
Fri Jul 30 05:38:40 EDT 2004
I use locals() for conveniently "filling out" SQL-Statements:
[snip]
def updData(id, surename):
sql="""update fisch set surename=%(surename)s where id=%(id)s"""
cs.execute(sql, locals())
[/snip]
that works great and is well within the definition of the python
db-api and is supported by pyPgSQL ... everything seems fine.
UNTIL
I read within psysco-FAQ and Jim Hugoninis IronPython paper: a lot of
words about "locals() being very difficult or impossible to optimize"
AND UNTIL
so ... is there any convenient replacement? Of course I could do
{"id":id, "surename":surename} , but that would be very very
in-elegant.
Harald
More information about the Python-list
mailing list