syntax for -c cmd

Fredrik Lundh fredrik at
Wed May 10 20:20:36 CEST 2006

James wrote:

> Wrong syntax is shown below. What should be the delimiter before else?
> python -c 'if 1==1: print "yes"; else print "no"'

there is no such delimiter.  Python's syntax doesn't allow you to put multiple
clauses on a single line.  if your shell supports it, use a "here document", or
embedded newlines.  if not, use a script.


More information about the Python-list mailing list