buggie in else syntax ?
stef mientki
tjollans at googlemail.com
Wed Aug 15 04:40:26 EDT 2007
Thomas Jollans wrote:
> On Tuesday 14 August 2007, stef mientki wrote:
>
>> hello,
>>
>> I've the idea that the "else" syntax is not always handled correctly,
>> or I'm overlooking something.
>>
>> This pieces of code are automatic translation from another language,
>> sometimes it works, sometimes it doesn't ???
>>
>> This piece of code works nice:
>>
>> a = 2
>>
>> def JSM (line_nr):
>> print line_nr
>>
>> if a>3:
>> print 'asddas'
>> else: JSM(230) ; \ <== this is the problem line, that's ok here
>> print 'aaps'
>>
>> While this piece of code gives a syntax error:
>>
>> #Function button_antidender(bit in pin,sbyte in out
>> Button_Counter_Temp,byte in demp) return bit is
>> def button_antidender ( pin, button_counter_temp, demp ):
>> #serial_hw_write(counter)
>> Serial_HW_Write ( button_counter_temp ) ;JSM(226)
>> if JSM(227) and ( button_counter_temp >= 0 ):
>> if JSM(228) and ( pin == on ):
>> button_counter_temp = button_counter_temp + 1
>> ;JSM(229)
>> else: JSM(230) ;
>> \ <=== SYNTAX ERROR
>>
>
> is there a newline before the backslash ? Or a space after the backslash but
> before the newline ?
>
>
I investigated this some further in a hex editor,
and indeed sometimes there's a space,
ok that's my stupid mistake.
But I found a situation that also in the very simple example always
gives a syntax error
a = 2
b = 5
def JSM (line_nr):
print line_nr
if a>3:
print 'asddas'
else: JSM(230) ; \
if b>3: <== SYNTAX ERROR pointing to the "f" of if
print 'bbbbb'
else:
print 'ccccc'
print 'aaps'
And I don't see the syntax error.
And if you're interested in the hex file data:
65 6C 73 65 3A 20 4A 53 4D 28 32 33 30 29 20 3B 20 5C 0D 0A
btw, I now split the else line over more than 1 line, and everything is
perfect.
thanks,
Stef Mientki
More information about the Python-list
mailing list