Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
"Dave Angel" wrote: 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 vari

Re: for-loop on cmd-line

2012-10-11 Thread Dave Angel
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,

RE: for-loop on cmd-line

2012-10-11 Thread Prasad, Ramit
Chris Angelico wrote: > On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem wrote: > > wrote in comp.lang.python > > > > (my ISP no longer updates this group. Last message is from 8. April. > > Does the postings to the python mailing-list automatically get reposted to > > comp.lang.python?) > > Yes, c.

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem wrote: > wrote in comp.lang.python > > (my ISP no longer updates this group. Last message is from 8. April. > Does the postings to the python mailing-list automatically get reposted to > comp.lang.python?) Yes, c.l.p and python-list mirror each other.

Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
wrote in comp.lang.python (my ISP no longer updates this group. Last message is from 8. April. Does the postings to the python mailing-list automatically get reposted to comp.lang.python?) C:\Windows\system32\python32.zip c:\python32\DLLs I see a similar result: f:\Windows\system32\python

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 3:24 AM, wrote: > Le jeudi 11 octobre 2012 15:16:33 UTC+2, Ramchandra Apte a écrit : > > PS C:\> $cmd="import sys;" > PS C:\> $cmd+="print('\n'.join(sys.path))" > PS C:\> $cmd > import sys;print('\n'.join(sys.path)) > PS C:\> c:\python32\python -c $cmd > > C:\Windows\syste

Re: for-loop on cmd-line

2012-10-11 Thread wxjmfauth
Le jeudi 11 octobre 2012 15:16:33 UTC+2, Ramchandra Apte a écrit : PS C:\> $cmd="import sys;" PS C:\> $cmd+="print('\n'.join(sys.path))" PS C:\> $cmd import sys;print('\n'.join(sys.path)) PS C:\> c:\python32\python -c $cmd C:\Windows\system32\python32.zip c:\python32\DLLs c:\python32\lib c:\pytho

Re: for-loop on cmd-line

2012-10-11 Thread Gisle Vanem
"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

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Fri, Oct 12, 2012 at 12:16 AM, Ramchandra Apte wrote: > What about the "Power" in PowerShell? What about it? Are you suggesting that the OP use it? Are you saying that Windows batch already includes it? You quoted my entire post (double-spaced), but that context adds nothing to your statement;

Re: for-loop on cmd-line

2012-10-11 Thread Ramchandra Apte
On Thursday, 11 October 2012 18:44:44 UTC+5:30, Chris Angelico wrote: > On Thu, Oct 11, 2012 at 11:16 PM, D'Arcy J.M. Cain wrote: > > > On Thu, 11 Oct 2012 13:24:22 +0200 > > > Gisle Vanem wrote: > > > > > >> Hello list. I'm a newbie when it comes to Python. > > >> > > >> I'm trying to tur

Re: for-loop on cmd-line

2012-10-11 Thread Chris Angelico
On Thu, Oct 11, 2012 at 11:16 PM, D'Arcy J.M. Cain wrote: > On Thu, 11 Oct 2012 13:24:22 +0200 > Gisle Vanem wrote: > >> Hello list. I'm a newbie when it comes to Python. >> >> I'm trying to turn this: >> >> def print_sys_path(): >> i = 0 >> for p in sys.path: >> print ('sys.path[%

Re: for-loop on cmd-line

2012-10-11 Thread D'Arcy J.M. Cain
On Thu, 11 Oct 2012 13:24:22 +0200 Gisle Vanem wrote: > Hello list. I'm a newbie when it comes to Python. > > I'm trying to turn this: > > def print_sys_path(): > i = 0 > for p in sys.path: > print ('sys.path[%2d]: %s' % (i, p)) > i += 1 > > into a one-line python command

Re: for-loop on cmd-line

2012-10-11 Thread Dave Angel
On 10/11/2012 07:24 AM, Gisle Vanem wrote: > Hello list. I'm a newbie when it comes to Python. > > I'm trying to turn this: > > def print_sys_path(): >i = 0 >for p in sys.path: > print ('sys.path[%2d]: %s' % (i, p)) > i += 1 > > into a one-line python command (in a .bat file): > >

Re: for-loop on cmd-line

2012-10-11 Thread suzaku
According to the document (http://docs.python.org/using/cmdline.html#interface-options), > When called with -c command, it executes the Python statement(s) given as > command. Here command may contain multiple statements separated by newlines. > Leading whitespace is significant in Python statem