Using something other than ';' to separate statements
andre.roberge at gmail.com
Wed Mar 30 21:57:53 CEST 2005
Jaime Wyant wrote:
> After goofing around with this idea, I've realized you can't be very
> expressive with a bunch of python statements strung together. My
> biggest problem is that I can't figure out (i don't think you can),
> how to do conditionals that are strung together:
> # This won't work
> if a > 5: print "a > 5";else print "Doh"
> I've decided to just call a function from the semicolon delimited
> record, using the return value in my `C' app...
The following might work based on the context:
code = '''if a > 5: \n print "a > 5"\nelse:\n print "Doh"\n'''
or, formatted differently
code = '''
if a > 5:
print "a > 5"
Then, you could do
> Yeah, I tried to "make it work", but it just won't. At least not in a
> satisfactory way.
More information about the Python-list