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: 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" To: Gisle Vanem Subject: Re: for-loop on cmd-line In-Reply-To: References: 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 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list 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: 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 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 (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 | 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