Re: for-loop on cmd-line

Discussion in 'Python' started by Dave Angel, Oct 11, 2012.

  1. Dave Angel

    Dave Angel Guest

    On 10/11/2012 09:40 AM, Gisle Vanem wrote:
    > "Dave Angel" <> wrote:
    >
    >> it has nothing to do with being on a command line. You're using
    >> semicolon to combine several statements, and there are restrictions on
    >> what can be combined that way. One restriction is the looping
    >> constructs, for, if, while.

    >
    > Ok, I suspected something like that.
    >
    >> You can do it easily enough with a list comprehension. Let us know if
    >> you can't work that out.

    >
    > Later. I'm only scratching the surface of Python.
    >
    >> Any reason why you don't just make a one-file python script, and run
    >> that instead of your one line batch file?

    >
    > I though of calling that python line from a C-program using
    > popen() and parsing the output. Since popen() on Win32 AFAIK doesn't
    > accept multiple lines, I guess I must write a .py-file to %TEMP first.
    >
    > Thank to all.
    >
    > --gv


    Why would you write some C-program just to save having two separate
    files, one batch and one for the script? For that matter, several
    answers have given you approaches that didn't involve list
    comprehensions, including merging the two in a single file, using an
    initial variable of rem="""

    What are your real constraints? Are you just playing code-golf?



    --

    DaveA
     
    Dave Angel, Oct 11, 2012
    #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. Achim Domma (Procoders)

    read input for cmd.Cmd from file

    Achim Domma (Procoders), Jun 3, 2005, in forum: Python
    Replies:
    2
    Views:
    8,113
    Peter Otten
    Jun 3, 2005
  2. Sarir Khamsi

    Interpreter-like help in cmd.Cmd

    Sarir Khamsi, Jun 9, 2005, in forum: Python
    Replies:
    4
    Views:
    390
    Bengt Richter
    Jun 26, 2005
  3. =?ISO-8859-1?Q?Sch=FCle_Daniel?=

    [exec cmd for cmd in cmds]

    =?ISO-8859-1?Q?Sch=FCle_Daniel?=, Mar 8, 2006, in forum: Python
    Replies:
    3
    Views:
    406
    Scott David Daniels
    Mar 8, 2006
  4. Diez B. Roggisch

    pydb remote debugging/cmd.Cmd over socket?

    Diez B. Roggisch, May 28, 2008, in forum: Python
    Replies:
    2
    Views:
    570
    Diez B. Roggisch
    May 29, 2008
  5. Isaac Won
    Replies:
    9
    Views:
    419
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page