Guido sees the light: PEP 8 updated

Marko Rauhamaa marko at pacujo.net
Mon Apr 18 05:17:25 EDT 2016


Gregory Ewing <greg.ewing at canterbury.ac.nz>:

> Marko Rauhamaa wrote:
>> Steven D'Aprano <steve at pearwood.info>:
>>
>>>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.
>
> Two things Python has that Pascal didn't are modules and classes. They
> take care of a lot of the grouping that you had to rely on nested
> functions for in Pascal.

I don't think Pascal did it for grouping or readability but for
conceptual correctness. When I moved from Pascal to C, I felt the
absence of local functions; it was a slight unease about abstraction
leakage.

> I do find myself nesting functions like that in Python, but only very
> occasionally.

Same for me. Essentially, I use local functions to register callbacks.
Decades of C has done that to us.


Marko



More information about the Python-list mailing list