Python handles globals badly.

Ian Kelly ian.g.kelly at gmail.com
Fri Sep 4 00:45:37 CEST 2015


On Thu, Sep 3, 2015 at 4:13 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
> On 03/09/2015 20:47, Ian Kelly wrote:
>>
>> On Thu, Sep 3, 2015 at 1:05 PM,  <tdev at freenet.de> wrote:
>>>
>>>      Or does anyone really name a global var xxx and a function var xxx?
>>>      I am sure no one at all will do it. I dont want read such a code.
>>
>>
>> Intentionally, it's probably rare. But if I'm adding a new variable, I
>> shouldn't need to first make sure that it's safe to do so by scanning
>> over the entire file to make sure that the name hasn't already been
>> used elsewhere in the opposite scope.
>>
>
> I'm just curious as I've never used it myself, but how does nonlocal
> https://docs.python.org/3/reference/simple_stmts.html#the-nonlocal-statement
> fit into this?

I don't know whether the proposal also applies to nonlocals, but such
conflicts would be less of an issue since you would only need to check
the outermost function scope (and also, nested functions aren't really
all that common).


More information about the Python-list mailing list