Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31132 > unrolled thread

Re: for-loop on cmd-line

Started byDave Angel <d@davea.name>
First post2012-10-11 16:40 -0400
Last post2012-10-11 16:40 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: for-loop on cmd-line Dave Angel <d@davea.name> - 2012-10-11 16:40 -0400

#31132 — Re: for-loop on cmd-line

FromDave Angel <d@davea.name>
Date2012-10-11 16:40 -0400
SubjectRe: for-loop on cmd-line
Message-ID<mailman.2065.1349988081.27098.python-list@python.org>
On 10/11/2012 09:40 AM, Gisle Vanem wrote:
> "Dave Angel" <d@davea.name> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web