git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Python-list Digest, Vol 186, Issue 31


On ven., Mar 29, 2019 at 4:51 PM, python-list-request at python.org wrote:
> On Thu, Mar 28, 2019 at 2:30 PM Alexey Muranov 
> <alexey.muranov at gmail.com>
> wrote:
>> 
>>  On jeu., mars 28, 2019 at 8:57 PM, Terry Reedy <tjreedy at udel.edu> 
>> wrote:
>>  > Throwing the name away is foolish.  Testing functions is another
>>  > situation in which function names are needed for proper report.
>> 
>>  My idea however was to have it as an exact synonyme of an 
>> assignment of
>>  a lambda. Assignment is an assignment, it should not modify the
>>  attributs of the value that is being assigned.
> 
> There could perhaps be a special case for lambda expressions such 
> that,
> when they are directly assigned to a variable, Python would use the
> variable name as the function name. I expect this could be 
> accomplished by
> a straightforward transformation of the AST, perhaps even by just 
> replacing
> the assignment with a def statement.

If this will happen, that is, if in Python assigning a lambda-defined 
function to a variable will mutate the function's attributes, or else, 
if is some "random" syntactically-determined cases

     f = ...

will stop being the same as evaluating the right-hand side and 
assigning the result to "f" variable, it will be a fairly good extra 
reason for me to go away from Python.

> Since this could just as easily be applied to lambda though, I'm 
> afraid it
> doesn't offer much of a case for the "f(x)" syntactic sugar.

I did not get this. My initial idea was exactly about introducing a 
syntactic sugar for better readability. I've already understood that 
the use cases contradict PEP 8 recommendations.

Alexey.