Disclaimer

The content of this blog is my personal opinion only. Although I am an employee - currently of Nvidia, in the past of other companies such as Iagination Technologies, MIPS, Intellectual Ventures, Intel, AMD, Motorola, and Gould - I reveal this only so that the reader may account for any possible bias I may have towards my employer's products. The statements I make here in no way represent my employer's position, nor am I authorized to speak on behalf of my employer. In fact, this posting may not even represent my personal opinion, since occasionally I play devil's advocate.

See http://docs.google.com/View?id=dcxddbtr_23cg5thdfj for photo credits.

Friday, March 25, 2016

AlternateLambdaSyntax - Python Wiki

It's fun to see the Python guys thrashing over lambda syntax.  Eventually Guido gave in and kept the historic lambda syntax.



AlternateLambdaSyntax - Python Wiki: "AlternateLambdaSyntax"



'via Blog this'



I must admit, I find the Python lambda syntax a bit unpleaasant:



Ordinary function

def foo(x):
      return x+1
Lambda

lambda  x: x+1
It is a pity thaat Pythin's lambdaas are not multiline:

http://stackoverflow.com/questions/1233448/no-multiline-lambda-in-python-why-not



This seems to be aa consequence of Python not being indentation sensitive inside parens.



I think that it is also a pity that Python's lambdas are strictly anonymous - although you can assign them a named variable.



I personally often use lambdas not just for anonymous functions, but also for named functions that I want to define near point of use, in the narrowest scope possible.



Even if they could be a lambda, naming them gives nicer stack traces.