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/2002-November/029962.html below:

would warnings be appropriate for probably-misused global statements?

[Python-Dev] Re: would warnings be appropriate for probably-misused global statements? [Python-Dev] Re: would warnings be appropriate for probably-misused global statements?Terry Reedy tjreedy@udel.edu
Wed, 6 Nov 2002 13:39:22 -0500
"Alex Martelli" <aleax@aleax.it> wrote in message
news:E189ShF-00064c-00@mail.python.org...
> I've recently helped clarify a few users' confusion about what the
"global"
> statement is for, and I'm starting to think that it might help
overcome that
> confusion if "global" gave warnings when used in
probably-inappropriate ways:
> not inside a function,

Yes.  This could even be made a syntax error, as with other contextual
statements:

>>> continue
SyntaxError: 'continue' not properly in loop
>>> break
SyntaxError: 'break' outside loop
# these messages should be same

>>> return 0
SyntaxError: 'return' outside function

# so why not " 'global' outside function"

> or about a variable that the function does not, in
> fact, bind nor re-bind.
No.  This can serve as documentation and/or preparation/protection for
possible revision that does rebind.

Terry J. Reedy







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