learning python ...

Alan Gauld alan.gauld at yahoo.co.uk
Mon May 24 19:36:41 EDT 2021


On 24/05/2021 19:48, Grant Edwards wrote:

>> Traceback (  File "<interactive input>", line 1
>>     if = 1.234
>>        ^
>> SyntaxError: invalid syntax
> 
> I must admit it might be nice if the compiler told you _why_ the
> syntax is invalid (e.g. "expected conditional expression while parsing
> 'if' statement").

Although wouldn't it be "expected boolean expression" rather than
conditional expression? Python doesn't care how the argument  to 'if'
is arrived at so long as it's a boolean. And with assignment
expressions, conditional expressions and literals all possible
unambiguous error messages get harder and harder to figure out.

But I do accept the general point that slightly more information
about syntax errors would be nice.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list