Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'win32': 0.03; 'lines,': 0.05; 'merging': 0.07; 'parsing': 0.07; 'python': 0.09; 'if,': 0.09; 'restriction': 0.09; 'script,': 0.09; 'cc:addr :python-list': 0.10; 'file,': 0.15; 'for,': 0.16; 'looping': 0.16; 'script?': 0.16; 'semicolon': 0.16; 'statements,': 0.16; 'wrote:': 0.17; 'restrictions': 0.17; 'variable': 0.20; 'cc:2**0': 0.23; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'guess': 0.27; 'separate': 0.27; 'first.': 0.27; "doesn't": 0.28; 'all.': 0.28; 'initial': 0.28; 'run': 0.28; "i'm": 0.29; 'that.': 0.30; "can't": 0.34; 'list': 0.35; 'something': 0.35; 'there': 0.35; "didn't": 0.36; 'thank': 0.36; 'enough': 0.36; 'ok,': 0.37; 'two': 0.37; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'nothing': 0.38; 'several': 0.39; 'instead': 0.39; 'received:192': 0.39; 'easily': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'your': 0.60; 'real': 0.61; 'save': 0.61; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'surface': 0.84; 'suspected': 0.84 Date: Thu, 11 Oct 2012 16:40:55 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: Gisle Vanem Subject: Re: for-loop on cmd-line References: <5076B379.4010503@davea.name> <75D2196AFD71466088D040B005B0BFFF@dev.null> In-Reply-To: <75D2196AFD71466088D040B005B0BFFF@dev.null> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:pZ+BVhB6XOD8RCSdbe350e1HOQwqAt1WSNk1VzrB1/8 zeHUIApfE19aegyJZuQp4FgFFhKEMm9ByXdlbo6d2wbNjiIMY0 xhxCOoeGy0CYIEaSOYArzZ2EKpOUPRqSmZq/+hJ9bBtN4Fb+we Gz3GHyV9AaKmkb1D06o1lr/uFtlZdfD4PZdVdnxc9MoWDlLAuQ 5BJix8G17WAz2nQ3zBk2JsxODV8oEclGbT5mqk5osw5K+r5rxN cQ6YH/GSP78exQ/eBkbhY/bKBFIp7h+3zfnfMkLvr1mdGvGWHO TsK1UH6uO017tqRHbnRE5GWiEL2+wObidSJDlV2KPbaiGv8yQ= = Cc: Python-list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: d@davea.name List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1349988081 news.xs4all.nl 6980 [2001:888:2000:d::a6]:53747 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31132 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