[Python-ideas] values in vs. values out
Alexander Belopolsky
alexander.belopolsky at gmail.com
Thu Jan 13 20:44:02 CET 2011
On Thu, Jan 13, 2011 at 2:27 PM, Masklinn <masklinn at masklinn.net> wrote:
> .. I don't see how it would be possible to replicate Python's breadth of arguments unpacking in return values.
What I do miss sometimes is the ability to inject the contents of a
dictionary into locals. For example, when I get the results of a
database query in a list of dictionaries or named tuples, I would like
to do something like
for <locals> in sql('select name, age from students'):
print(name, age)
I can achieve that with hacks like
for x in sql('select name, age from students'):
locals().update(*x)
print(name, age)
but I don't think this is guaranteed to work and it is ugly and inefficient.
More information about the Python-ideas
mailing list