Help with syntax warnings

Peter Hansen peter at engcorp.com
Fri Sep 30 13:30:56 CEST 2005


Robert Kern wrote:
> Peter Hansen wrote:
>>Not sure... what's a "syntax warning"?
> 
> In [1]: SyntaxWarning?
> Type:           classobj
> String Form:    exceptions.SyntaxWarning
> Namespace:      Python builtin
> Docstring:
>     Base class for warnings about dubious syntax.

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

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

I guess I've never accidentally hit one of those.  Seems like, if I had, 
I'd probably want to fix the problem rather than hide it, as with most 
warnings from C compilers.

-Peter



More information about the Python-list mailing list