A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-January/151625.html below:

[Python-Dev] Whatever happened to 'nonlocal x = y'?

[Python-Dev] Whatever happened to 'nonlocal x = y'? [Python-Dev] Whatever happened to 'nonlocal x = y'?Random832 random832 at fastmail.com
Fri Jan 5 13:48:32 EST 2018
On Fri, Jan 5, 2018, at 10:47, Guido van Rossum wrote:
> I don't recall (though someone with more time might find the discussion in
> the archives or on the tracker). It was never implemented and I think it
> shouldn't be. So we might as well update the PEP. It wouldn't be
> particularly useful, since (by definition) the function that declares the
> nonlocal variable is not its owner, and hence it's unlikely to make sense
> to initialize it here. The same reasoning applies to global BTW.

I'm not so sure...

The only situation in which you're *required* to declare a nonlocal/global variable, after all, is if you intend to assign it - a name that you never assign is presumed to be non-local. The description in the PEP also applies to augmented assignments, and "global some_counter; some_counter += 1" is certainly a pattern I've needed in the past.

The PEP also quotes you as endorsing this for global. https://mail.python.org/pipermail/python-3000/2006-November/004166.html
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4