Keen eyes

Chris Angelico rosuav at gmail.com
Sun Jan 17 03:25:29 EST 2016


On Sun, Jan 17, 2016 at 6:37 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> Technically it defaults to non local. The var statement allocates a
> variable within the current scope. Otherwise it searches up the chain of
> parent scopes for a matching variable...

This far, it's exactly the same as C.

> ... terminating at the global scope.

This is the bit that gets ridiculous. Undeclared variables in C are
compile-time errors. Undeclared variables in JS are implicit globals.
This is stupid.

Oh, plus the fact that you can have "var x;" anywhere but it always
applies to the whole function. But most of the time, that won't bite
you.

ChrisA



More information about the Python-list mailing list