[Python-ideas] Anonymous blocks (again):

Terry Jan Reedy tjreedy at udel.edu
Mon May 13 19:53:17 CEST 2013


On 5/13/2013 1:23 PM, Juancarlo Añez wrote:
>
> On Mon, May 13, 2013 at 11:58 AM, Terry Jan Reedy
> <tjreedy at udel.edu
> <mailto:tjreedy at udel.edu>> wrote:
>
>     I disagree that the above is unpythonic. In Python, functions are
>     objects like everything else. Define them, pass them to functions,
>     like anything else. 'Unpythonic' is treating functions as special,
>     other than that they are called (have a call method).
>
>
> I beg to disagree. Functions are objects in python, but they get
> particular treatment.

So do classes, modules, ...,

> You can do:
>
>     def f():
>          pass
>     x = f
>
> But you can't do:
>
>     x = def(): pass

So what? Really. There is nothing particular about that.
Neither can you do

x = class (): pass
x = with open(..):
x = import itertools
x = if True: y = 3
x = <pick any statement other than expression/binding statements>

The fact that Python is a mixed syntax language with both expressions 
and statements is fundamental to its design.

--
Terry Jan Reedy





More information about the Python-ideas mailing list