My first script (so go easy on me!)

Sandipan Gangopadhyay sandipan at vsnl.com
Tue Jan 16 14:22:41 EST 2001


I have this strange feeling that the original post asked if

>>> print "some kind of command string"

executes the command string or does it require an explicit line-feed to get
the system to execute it ?

Is it possible that I am right ?

In that case, what is required is the os.system("command string")

Regards,

Sandipan

----- Original Message -----
From: "Erik Max Francis" <max at alcyone.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Tuesday, January 16, 2001 11:10 PM
Subject: Re: My first script (so go easy on me!)


> Robert L Hicks wrote:
>
> > Is this ok?
>
> It works, though I'd do a safer comparison with actual strings, like:
>
>     if answer == 'yes':
>         print r
>     elif answer == 'no':
>         print w
>     else:
>         print n
>
> Note what happens in your program if you answer `nope' instead of `no'.
> You could also just key off the first character:
>
>     if answer[0] == 'y':
>         print r
>     elif answer[0] == 'n':
>         print w
>     ...
>
> You also don't particularly gain anything in this tiny example by saving
> the strings you want to print off into variables that you use later,
> although in what you're planning to do, it might make sense eventually;
> it's certainly not wrong.
>
> > My question is when the print statement is run do I need
> > to do a
> > linefeed so the terminal accepts what was printed? Or does the fact
> > that
> > python send the print to the terminal cause the terminal to execute
> > it?
>
> An unadorned print statement implicitly has a newline stuck to the end
> of it, and comma-separated items are printed with intervening spaces.
> So you can write things like:
>
>     i = 10
>     print "The number of items left is", i
>
> To suppress the trailing newline, end with a comma (but it will end with
> a trailing space):
>
>     print "Do you want to quit?",
>
> --
>  Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
>  __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
> /  \ I am the king of sorrow
> \__/ Sade
>     Official Buh rules / http://www.alcyone.com/max/projects/cards/buh/
>  The official rules to the betting card game, Buh.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20010117/85dbf948/attachment.html>


More information about the Python-list mailing list