Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31112
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <darcy@druid.net> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'newbie': 0.05; 'sys': 0.05; 'python': 0.09; "%s'": 0.09; '425': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'file):': 0.16; 'im:': 0.16; 'oct': 0.16; 'sys.path:': 0.16; 'wrote:': 0.17; 'thu,': 0.17; '(in': 0.18; 'windows': 0.19; '+0200': 0.20; 'trying': 0.21; 'import': 0.21; 'voting': 0.22; 'cc:2**0': 0.23; 'this:': 0.23; 'command': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'actual': 0.28; 'run': 0.28; "i'm": 0.29; 'not.': 0.32; 'print': 0.32; 'list.': 0.35; 'charset:us-ascii': 0.36; 'skip:p 20': 0.36; 'turn': 0.36; 'subject:: ': 0.38; 'subject:-': 0.40; 'democracy': 0.84; 'received:98.158': 0.84; '"one': 0.91 |
| Date | Thu, 11 Oct 2012 08:16:07 -0400 |
| From | "D'Arcy J.M. Cain" <darcy@druid.net> |
| To | Gisle Vanem <gvanem@broadpark.no> |
| Subject | Re: for-loop on cmd-line |
| In-Reply-To | <E7295A9F2EFF4FD0A64C1225370AAC56@dev.null> |
| References | <E7295A9F2EFF4FD0A64C1225370AAC56@dev.null> |
| X-Mailer | Claws Mail 3.8.1 (GTK+ 2.24.13; x86_64--netbsd) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Cc | Python-list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2046.1349958307.27098.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1349958307 news.xs4all.nl 6942 [2001:888:2000:d::a6]:52116 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31112 |
Show key headers only | View raw
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: for-loop on cmd-line "D'Arcy J.M. Cain" <darcy@druid.net> - 2012-10-11 08:16 -0400
csiph-web