module attributes and docstrings

Mario Figueiredo marfig at gmail.com
Thu Mar 26 05:53:48 EDT 2015


On Tue, 24 Mar 2015 15:33:41 -0400, Terry Reedy <tjreedy at udel.edu>
wrote:

>
>You have discovered one of advantages of a def statement over a 
>name=lambda assignment statement.  In Python, there is no good reason to 
>use the latter form and PEP 8 specifically discourages it: "Always use a 
>def statement instead of an assignment statement that binds a lambda 
>expression directly to an identifier."

Chris also suggested me this. And frankly, I don't see why I shouldn't
follow that advise. It's good advice.

However, lambda functions do read well in my mind and I find it hard
to spot where they obscure the code more than a function. So the
explicit vs. implicit part of the argument doesn't translate well with
me. I however agree that a function declaration brings other benefits,
like the ability to decorate or document.

I will reserve the use of lambdas to only where they are necessary.
Thanks.



More information about the Python-list mailing list