n = lambda x: print x

Warren Postma embed at geocities.com
Thu May 4 09:18:34 EDT 2000


In a moment of perverse glee, I decided to type the statement in to see what
it does.  The question I wondered was, if Python accepted this:

n = lambda x: print x

What would it do with this:

n = (lambda x: print x,y)

Is the comma part of the print statement, or would n become a tuple of two
values? :-)

Is the first construct s pecifically disallowed in the python grammar
somehow? print is a bit of a weirdball function in that it is invoked
without parenthesis. (The most BASIC-like feature of Python).

Could we in fact say that if fewer exceptions to rules makes a language
simpler then the PRINT statement is a bad idea and a PRINT( x,y,z) function
would have been a much better idea?

Why did Guido not parenthesize arguments to PRINT when designing Python?
Look, a Syn! Otherwise, this language is perfect. ;-) I love Python.

Warren






More information about the Python-list mailing list