Static variables [was Re: syntax difference]

Marko Rauhamaa marko at pacujo.net
Mon Jun 25 14:58:25 EDT 2018


Grant Edwards <grant.b.edwards at gmail.com>:
> IOW, you use a local function instead of a global one for the exact
> same reasons you use local "variables" instead of global ones.
>
> In Python, functions are first class objects.  Binding a name to a
> function is no different than binding it to an integer, list, string,
> or dict.  Don't the global vs. local cost vs. benefit calculations
> apply equally well to function objects as they do to those other sorts
> of objects?

Precisely!

The most important reason to use inner functions or inner classes is
that it's cromulent for the task at hand, stylistically opportune or
optimal, not to use the word Pythonic.


Marko



More information about the Python-list mailing list