Neat way to get rid of [" "] in sys.argv[n:] returns

Discussion in 'Python' started by korean_dave, Jul 24, 2008.

  1. korean_dave

    korean_dave Guest

    so, i code this:
    -----------------------------
    #!/usr/bin/python

    import sys
    import os

    for param in os.environ.keys():
    print "%20s %s" % (param,os.environ[param])

    print(os.environ['PATH'])

    print(sys.argv[1:])
    --------------------------
    and then when i type in -->

    python test.py "testparameter"

    I get this output:

    -------------
    ['testparameter']
    ----------------

    Is there a way to neatly, in one call to the parameter, to get rid of
    the [' and '] without bothering to replace() '[ with "" and replace()
    '] with ''?

    Thanks,
    korean_dave, Jul 24, 2008
    #1
    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. =?ISO-8859-1?Q?Thomas_N=FCcker?=

    sys.argv[0] - 'module' object has no attribute 'argv'

    =?ISO-8859-1?Q?Thomas_N=FCcker?=, Jun 30, 2003, in forum: Python
    Replies:
    0
    Views:
    901
    =?ISO-8859-1?Q?Thomas_N=FCcker?=
    Jun 30, 2003
  2. Grant Edwards
    Replies:
    3
    Views:
    584
    Grant Edwards
    Aug 11, 2004
  3. happykid
    Replies:
    6
    Views:
    636
    WaffleSouffle
    Aug 9, 2011
  4. Tim McDaniel
    Replies:
    2
    Views:
    375
    Tim McDaniel
    Aug 27, 2012
  5. hymie!
    Replies:
    1
    Views:
    356
    Tim McDaniel
    Aug 27, 2012
Loading...

Share This Page