Command line input

Discussion in 'Python' started by hexusnexus@gmail.com, Mar 31, 2008.

  1. Guest

    How do I receive input from the command line in Python?
     
    , Mar 31, 2008
    #1
    1. Advertising

  2. 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
     
    Marc 'BlackJack' Rintsch, Mar 31, 2008
    #2
    1. Advertising

  3. Jorgen Grahn Guest

    On 31 Mar 2008 20:13:05 GMT, Marc 'BlackJack' Rintsch <> wrote:
    > 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!
     
    Jorgen Grahn, Mar 31, 2008
    #3
  4. Rick Dooling Guest

    On Mar 31, 2:39 pm, 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'
     
    Rick Dooling, Apr 1, 2008
    #4
  5. Guest

    On Mar 31, 4:04 pm, Rick Dooling <> wrote:
    > On Mar 31, 2:39 pm, 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, 2008
    #5
  6. Paul Scott Guest

    On Mon, 2008-03-31 at 12:39 -0700, 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/portal_services/disclaimer.htm
     
    Paul Scott, Apr 1, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,111
    Tohid
    Oct 23, 2003
  2. Bernd Oninger
    Replies:
    1
    Views:
    828
    Martin Honnen
    Jul 7, 2004
  3. Replies:
    4
    Views:
    1,745
    Terry Hancock
    Apr 23, 2005
  4. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    267
    Genich
    Oct 22, 2003
  5. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page.

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    230
    Oliver
    Oct 22, 2003
Loading...

Share This Page