Spot the invalid syntax

Terry Reedy tjreedy at udel.edu
Thu Mar 8 19:15:45 EST 2018


On 3/8/2018 6:30 PM, Ben Finney wrote:
> Ian Pilcher <arequipeno at gmail.com> writes:
> 
>>>                  ips.update(_san_dnsname_ips(cname, True)
                                 | <= auto-indent
If you type this code line in IDLE or other decent Python-aware code 
editor, the smart indent would put curser where I put the '|', thus 
indicating that there is no ')' matching the function call '('

>>>      return ips

If you delete the helpful indent signal to type return here, ...

>>
>> 2.7 and 3.6 are both giving me:
>>
>>    File "/tmp/test.py", line 32
>>      return ips
>>           ^
>> SyntaxError: invalid syntax
>>
>> I've checked for tabs and mismatched parentheses.

IDLE, etc, flashes the ([{ opener for every )]} closer typed.
Not seeing an expected flash and seeing an unexpected indent catches 
most mismatches for me.

> Not sufficiently, it seems. Check the line preceding the ‘return’
> statement.
> 
> Then, switch to using a programmer's text editor (I prefer Emacs) that
> can spot these syntax errors while you type.
I have never used Emacs, but I understand it has a decent Python-aware mode.

-- 
Terry Jan Reedy





More information about the Python-list mailing list