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


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

Re: for-loop on cmd-line

Started by"D'Arcy J.M. Cain" <darcy@druid.net>
First post2012-10-11 08:16 -0400
Last post2012-10-11 08:16 -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 "D'Arcy J.M. Cain" <darcy@druid.net> - 2012-10-11 08:16 -0400

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

From"D'Arcy J.M. Cain" <darcy@druid.net>
Date2012-10-11 08:16 -0400
SubjectRe: for-loop on cmd-line
Message-ID<mailman.2046.1349958307.27098.python-list@python.org>
On Thu, 11 Oct 2012 13:24:22 +0200
Gisle Vanem <gvanem@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 command (in a .bat file):

Is "one liner" an actual requirement or is the requirement to run it
from the command line?

python -c "
import sys
i = 0
for p in sys.path:
  print('sys.path[%2d]: %s' % (i, p))
  i+=1
"

I don't know if this works on Windows or not.

-- 
D'Arcy J.M. Cain <darcy@druid.net>         |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.
IM: darcy@Vex.Net

[toc] | [standalone]


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


csiph-web