buggie in else syntax ?
James Stroud
jstroud at mbi.ucla.edu
Tue Aug 14 17:28:12 EDT 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
> button_counter_temp = 1
> ;JSM(231)
>
> Traceback (most recent call last):
> File "D:\data_to_test\JALsPy\JALsPy.py", line 347, in ?
> Run_JALsPy_Application ()
> File "D:\data_to_test\JALsPy\JALsPy.py", line 327, in
> Run_JALsPy_Application
> JG.app.MainLoop()
> File "D:\data_to_test\JALsPy\JALsPy.py", line 255, in MainLoop
> import JAL_simulation_file
> File "D:\data_to_test\JALsPy\JAL_simulation_file.py", line 265
> else: JSM(230) ; \
>
> I guess it's not the preferred syntax, but the resemblance with the
> original language it optimal.
> Why is it sometimes accepted an sometimes give an error message ?
>
> thanks,
> Stef Mientki
>
>
Looks like you've escaped a space.
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
More information about the Python-list
mailing list