On Thu, Aug 18, 2016 at 7:32 PM, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
> So I don't see any
> benefit over this:
>
>          for section_name, line_number in text.parser.toc:
>              drop.add_command(label=section_name, command=lambda
>                               line=line_number: text.yview(line))
>
> except that it is easier to fit in 79 columns :-)

Which is a VERY important benefit when you realize what's just
happened to your code. Wrapping after "command=lambda" and before
"line=linenumber" majorly obscures what's going on here. Here's a
better way to wrap that:

         for section_name, line_number in text.parser.toc:
             drop.add_command(label=section_name,
                    command=lambda line=line_number: text.yview(line))

However, this isn't an indictment of lambda, just proof that anyone
can misalign stuff by mistake.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to