Replacement for locals() ???

Harald Armin Massa haraldarminmassa at
Fri Jul 30 11:38:40 CEST 2004

I use locals() for conveniently "filling out" SQL-Statements:


def updData(id, surename):
   sql="""update fisch set surename=%(surename)s where id=%(id)s"""
   cs.execute(sql, locals())


that works great and is well within the definition of the python
db-api and is supported by pyPgSQL ... everything seems fine.


I read within psysco-FAQ and Jim Hugoninis IronPython paper: a lot of
words about "locals() being very difficult or impossible to optimize"


so ... is there any convenient replacement? Of course I could do

{"id":id, "surename":surename} , but that would be very very


More information about the Python-list mailing list