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
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
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
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
"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
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
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
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