Functions Of Functions Returning Functions

Steve D'Aprano steve+python at pearwood.info
Sun Sep 18 07:21:50 EDT 2016


On Sun, 18 Sep 2016 08:28 pm, Lawrence D’Oliveiro wrote:

> This shows the power of functions as first-class objects. The concept
> is older than object orientation, and is often left out of
> object-oriented languages. I think Python benefits from the fact that
> it had functions before it had classes.

You're right about Python having functions first:

steve at runes:~$ python0.9.1
>>> def f():
...     pass
...
>>> class A:
Parsing error: file <stdin>, line 1:
class A:
        ^
Unhandled exception: run-time error: syntax error



However it only gained closures and nested scopes in Python 2.2, or with a
__future__ directive in 2.1.


https://www.python.org/dev/peps/pep-0227/




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list