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/2003-March/034289.html below:

[Python-Dev] Compiler treats None both as a constant and variable

[Python-Dev] Compiler treats None both as a constant and variable [Python-Dev] Compiler treats None both as a constant and variableGuido van Rossum guido@python.org
Sun, 30 Mar 2003 14:02:38 -0500
> >>> def f():
>  None  
> 
> >>> dis(f)
> 2           0 LOAD_GLOBAL              0 (None)
>               3 POP_TOP             
>               4 LOAD_CONST               0 (None)
>               7 RETURN_VALUE 
> 
> >>> None = 1
> <stdin>:1: SyntaxWarning: assignment to None
> >>> f() == None
> False
> 
> 
> Is this a bug?

Yes, assigning to None is a bug. :-)

> Should the compiler use the GLOBAL in both places?

No, not until we've officially changed the rules.

> Or, is it reasonable to use CONST in both places?

No, not until assigning to None is an error rather than a warning.
This will have to wait until at least 2.4 -- the warning is new in
2.3.

--Guido van Rossum (home page: http://www.python.org/~guido/)



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