python programming help

Terry Reedy tjreedy at
Sun Dec 8 22:17:56 CET 2013

On 12/8/2013 2:06 PM, rafaellasav at wrote:

Even when you do get what lambda means and how use it,
   name = lambda args: expression
which is a carryover from other languages, is inferior to
   def name(args): return expression
because the function object resulting from lambda does not have a proper 
name attribute.

> def people(age):
>      people=[name for name in dic if dic[name]==age]

An alternative is
[name for name, value in dic.itervalues() if value == age]

In Python 3, remove 'iter'. It this is not homework and you are not 
otherwise forced to start with Python 3, I (and some others here) 
recommend starting with Python 3.

Terry Jan Reedy

More information about the Python-list mailing list