Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32070
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: while expression feature proposal |
| References | <mailman.2795.1351111299.27098.python-list@python.org> |
| Date | 2012-10-24 15:19 -0700 |
| Message-ID | <7xehkno6n1.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
Dan Loewenherz <dloewenherz@gmail.com> writes: > VAR = EXPR > while VAR: > BLOCK > VAR = EXPR for VAR in iter(lambda: EXPR, None): BLOCK where the termination sentinel might be False or '' or whatever instead of None. Of course if EXPR is a callable, there's no lambda. > while EXPR as VAR: > BLOCK This is kind of nice. I wonder if it could generalize "with" somehow, i.e. use the context manager for EXPR if it has one. Or maybe "iter" could be generalized so you could pass an arbutrary predicate as termination condition, instead of a single sentinel value.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
while expression feature proposal Dan Loewenherz <dloewenherz@gmail.com> - 2012-10-24 13:40 -0700 Re: while expression feature proposal Paul Rubin <no.email@nospam.invalid> - 2012-10-24 15:19 -0700
csiph-web