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


Groups > comp.lang.python > #12614

Re: idiomatic analogue of Perl's: while (<>) { ... }

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
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.01; 'subject:while': 0.07; 'python': 0.08; 'none:': 0.09; 'parsing': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'converting': 0.15; '"none"': 0.16; "'w',": 0.16; 'approach,': 0.16; 'bieber': 0.16; 'declaimed': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'input,': 0.16; 'received:66.245': 0.16; 'received:dsl.mindspring.com': 0.16; 'received:mindspring.com': 0.16; 'received:wlfraed': 0.16; 'stdout': 0.16; 'sys.stdout': 0.16; 'tasked': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'wulfraed': 0.16; 'perl': 0.18; 'url:home': 0.21; 'wonder': 0.23; 'sep': 0.23; 'input': 0.24; 'preferred': 0.25; 'language.': 0.28; 'lee': 0.28; 'thu,': 0.28; 'exit': 0.29; 'print': 0.29; 'there': 0.33; 'to:addr:python-list': 0.33; "i've": 0.34; '(as': 0.34; 'consensus': 0.34; 'searches': 0.34; 'header:X-Complaints-To:1': 0.35; 'object': 0.35; 'charset :us-ascii': 0.36; 'but': 0.37; 'received:org': 0.38; 'some': 0.38; 'subject:: ': 0.39; 'ok,': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'more': 0.60; 'skip:o 30': 0.63; 'note:': 0.68; 'soon': 0.72; 'dennis': 0.77
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: idiomatic analogue of Perl's: while (<>) { ... }
Date Thu, 01 Sep 2011 22:19:20 -0700
Organization > Bestiaria Support Staff <
References <20110901045650.GA3466@magic.hamla.org>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host user-11fb66t.dsl.mindspring.com
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.684.1314940781.27778.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314940781 news.xs4all.nl 2429 [2001:888:2000:d::a6]:37932
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12614

Show key headers only | View raw


On Thu, 1 Sep 2011 00:56:50 -0400, Sahil Tandon <sahil@FreeBSD.org>
declaimed the following in gmane.comp.python.general:

> I've been tasked with converting some programs from Perl -> Python, and
> am (as will soon be obvious) new to the language.  A few archive/google
> searches were inconclusive on a consensus approach, which is OK, but I
> just wonder if there is a more Python-esque way to do the following in
> Python 2.7.1:
> 
> %%
> # unbuffer STDOUT
> sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
> 
> # process input, line-by-line, and print responses after parsing input 
> while 1:
>   rval = parse(raw_input())
>   if rval == None:

	There is only ONE "None" object so the preferred method is

	if rval is None:


	Note: I don't see any exit handler/condition...
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: idiomatic analogue of Perl's: while (<>) { ... } Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2011-09-01 22:19 -0700

csiph-web