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):
python -c import sys,os; i=0; for p in sys.path:
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
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):
python -c
On Thu, 11 Oct 2012 13:24:22 +0200
Gisle Vanem gva...@broadpark.no 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
On Thu, Oct 11, 2012 at 11:16 PM, D'Arcy J.M. Cain da...@druid.net wrote:
On Thu, 11 Oct 2012 13:24:22 +0200
Gisle Vanem gva...@broadpark.no 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:
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 da...@druid.net wrote:
On Thu, 11 Oct 2012 13:24:22 +0200
Gisle Vanem gva...@broadpark.no wrote:
Hello list. I'm a newbie when it comes to Python.
I'm
On Fri, Oct 12, 2012 at 12:16 AM, Ramchandra Apte
maniandra...@gmail.com 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
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
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:\python32
On Fri, Oct 12, 2012 at 3:24 AM, wxjmfa...@gmail.com 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
wxjmfa...@gmail.com 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:
On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem gva...@broadpark.no wrote:
wxjmfa...@gmail.com 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
Chris Angelico wrote:
On Fri, Oct 12, 2012 at 3:49 AM, Gisle Vanem gva...@broadpark.no wrote:
wxjmfa...@gmail.com 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
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,
Dave Angel d...@davea.name 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
15 matches
Mail list logo