Gregory Ewing <greg.ew...@canterbury.ac.nz>: > Marko Rauhamaa wrote: >> Steven D'Aprano <st...@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 -- https://mail.python.org/mailman/listinfo/python-list