Functional programming

Chris Angelico rosuav at gmail.com
Tue Mar 4 17:04:36 CET 2014


On Wed, Mar 5, 2014 at 2:45 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
>> Aside: If you declare your locals, you shouldn't need to declare your
>> globals. Though I could imagine a rule that global rebinding still needs
>> to be declared, but you certainly shouldn't need to declare nonlocal if
>> you have a local declaration. Absence of local => nonlocal.
>
> You missed that the purpose of the declaration is to avoid accidental
> typos:
>
> local process
> procces = 1234
>
>
> With declarations, the compiler can catch some typos at compile-time.

Yep, but if you're declaring all your locals (and globals get declared
at module scope - they're just local to a different and broader
scope), then "procces" will never have been declared anywhere. You
shouldn't need to re-declare everything you're referencing from an
outer scope.

ChrisA



More information about the Python-list mailing list