On Sun, May 4, 2008 at 3:31 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
   ...
>   for k,g in groupby(iterable, key=lambda r: (r[0].lower(), r[5].lower())):
> ...
>     lastname_firstname = lambda r: (r[0].lower(), r[5].lower())
>   for k, g in groupby(iterable, key=lastname_firstname): ...
>
>  That transformation adds clarity.  Going further and creating a separate
>  def-statement outside the current function would just move the relevant
>  code farther away and impair readability.

And that would be totally silly and uncalled for -- why ever would it
be placed *outside the current function*?!  What a straw-man...!  Just
do

def last_first(r): return r[0].lower(), r[5].lower()
for k, g in groupby(iterable, key=last_first): ...

putting the def right where you now have the "<name> = lambda ..." of course!

Alex
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to