471,089 Members | 1,097 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Command line input

How do I receive input from the command line in Python?
Mar 31 '08 #1
5 1497
On Mon, 31 Mar 2008 12:39:54 -0700, hexusnexus wrote:
How do I receive input from the command line in Python?
Direct way `sys.argv`, comfortable way `optparse`.

Ciao,
Marc 'BlackJack' Rintsch
Mar 31 '08 #2
On 31 Mar 2008 20:13:05 GMT, Marc 'BlackJack' Rintsch <bj****@gmx.netwrote:
On Mon, 31 Mar 2008 12:39:54 -0700, hexusnexus wrote:
>How do I receive input from the command line in Python?

Direct way `sys.argv`, comfortable way `optparse`.
I have a feeling he doesn't mean command-line arguments to the
program, but typing on the keyboard after the program has started.
If that is the case:

Direct way `sys.stdin`, many other fancy ways.

/Jorgen

--
// Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
\X/ snipabacken.se R'lyeh wgah'nagl fhtagn!
Mar 31 '08 #3
On Mar 31, 2:39 pm, hexusne...@gmail.com wrote:
How do I receive input from the command line in Python?
As long as we are all guessing, do you perhaps mean raw_input?

my_name = raw_input("What is your name? ")
What is your name? Rick <ENTER>
>>my_name
'Rick'

Mar 31 '08 #4
On Mar 31, 4:04 pm, Rick Dooling <rpdool...@gmail.comwrote:
On Mar 31, 2:39 pm, hexusne...@gmail.com wrote:
How do I receive input from the command line in Python?

As long as we are all guessing, do you perhaps mean raw_input?

my_name = raw_input("What is your name? ")
What is your name? Rick <ENTER>>>my_name

'Rick'
Yeah, sorry for being vague. Thanks.
Apr 1 '08 #5

On Mon, 2008-03-31 at 12:39 -0700, he********@gmail.com wrote:
How do I receive input from the command line in Python?
I have used:

sys.argv[ 1 ]

I have been doing Python for around 2 days now, so please do double check that!

--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/public/p...disclaimer.htm

Apr 1 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Samantha Smit | last post: by
7 posts views Thread by David A. Osborn | last post: by
34 posts views Thread by Roman Mashak | last post: by
6 posts views Thread by evantri | last post: by
4 posts views Thread by Keith Hughitt | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.