Functional programming

Steven D'Aprano steve+comp.lang.python at
Tue Mar 4 16:45:51 CET 2014

On Wed, 05 Mar 2014 02:28:17 +1100, Chris Angelico wrote:

> On Wed, Mar 5, 2014 at 2:18 AM, Steven D'Aprano
> <steve+comp.lang.python at> wrote:
>> You don't need to have static typing to have declared variables. The
>> two are independent. E.g. one might have a system like Python, except
>> you have to declare your variables before using them:
>> global x
>> local a
>> a = x+1
> 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 

local process
procces = 1234

With declarations, the compiler can catch some typos at compile-time.

Steven D'Aprano

More information about the Python-list mailing list