Guido sees the light: PEP 8 updated

Marko Rauhamaa marko at pacujo.net
Mon Apr 18 04:02:40 EDT 2016


Steven D'Aprano <steve at pearwood.info>:

> One technique which is common in Pascal, but less so in Python, is to get
> the best of both worlds by using nested functions. In Python syntax:
>
> def Do_The_Thing():
>     def internal_subpart_start(): ...
>     def internal_subpart_middle(): ...
>     def internal_subpart_end(): ...
>     ...

That really should be done more. C weaned us from the routine Pascal
mechanism, but there's no reason not to exploit it again in Python. It
also solves the problem of lugging the local context between internal
functions, especially now that Python possesses the "nonlocal" keyword.


Marko



More information about the Python-list mailing list