Re: syntax for -c cmd

2006-05-12 Thread Edward Elliott
Fredrik Lundh wrote: > hint: > > $ python -c 'import sys; print sys.argv' 'else: print "no"' > > Yeah the man page knows all. About the only time I use python on the command line is with the timeit module, which evals all arguments given. Hence the confusion. -- Edward Elliott UC Berke

Re: syntax for -c cmd

2006-05-11 Thread Fredrik Lundh
Edward Elliott wrote: > Now this is interesting. I broke the line up into separate arguments and it > seemed to work fine: > > $ python -c 'if 1==1: print "yes"' 'else: print "no"' > yes > > But then I tested the else branch and it produces no output: > $ python -c 'if 1==0: print "yes"' 'else: p

Re: syntax for -c cmd

2006-05-11 Thread Edward Elliott
Dennis Lee Bieber wrote: > On Thu, 11 May 2006 20:12:55 GMT, Edward Elliott <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > >> If putting the else in a separate arg unbinds it from the if, I would >> expect a syntax error. If OTOH naked elses are allowed on the command >> li

Re: syntax for -c cmd

2006-05-11 Thread Edward Elliott
James wrote: > Wrong syntax is shown below. What should be the delimiter before else? > > python -c 'if 1==1: print "yes"; else print "no"' Now this is interesting. I broke the line up into separate arguments and it seemed to work fine: $ python -c 'if 1==1: print "yes"' 'else: print "no"' yes

Re: syntax for -c cmd

2006-05-10 Thread Paul McGuire
"James" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Wrong syntax is shown below. What should be the delimiter before else? > > python -c 'if 1==1: print "yes"; else print "no"' > > James > So you can approximate this same logic with a boolean expression: print (1==1 and "yes" or

Re: syntax for -c cmd

2006-05-10 Thread Simon Brunning
On 5/10/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > 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

Re: syntax for -c cmd

2006-05-10 Thread Fredrik Lundh
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", o

syntax for -c cmd

2006-05-10 Thread James
Wrong syntax is shown below. What should be the delimiter before else? python -c 'if 1==1: print "yes"; else print "no"' James -- http://mail.python.org/mailman/listinfo/python-list