Help with syntax warnings

Fredrik Lundh fredrik at pythonware.com
Fri Sep 30 10:08:21 EDT 2005


Peter Hansen wrote:

> Wow... Python detects "dubious syntax"?  And here I thought programming
> was rather black and white, it's right or it's wrong.

SyntaxWarnings are issued for things that has never been valid nor well-
defined nor especially clever, but has been handled (in some more or less
reasonable way) by the CPython compiler.  In practice, syntax warnings
will turn into errors in future releases.

> (He notes examples such as assigning to None and "unqualified exec is
> not allowed in function" etc.)

Compare and contrast:

Python 2.3.4 (#53, May 25 2004, 21:17:02)
>>> None = "hello"
<stdin>:1: SyntaxWarning: assignment to None

Python 2.4.1 (#65, Mar 30 2005, 09:13:57)
>>> None = "hello"
SyntaxError: assignment to None

</F> 






More information about the Python-list mailing list