Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20220
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.chainon-marquant.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!74.125.46.80.MISMATCH!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
|---|---|
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Postpone evaluation of argument |
| Date | Sat, 11 Feb 2012 03:16:39 -0800 (PST) |
| Organization | http://groups.google.com |
| Lines | 35 |
| Message-ID | <412049.429.1328958999552.JavaMail.geo-discussion-forums@pbctz8> (permalink) |
| References | <mailman.5686.1328914914.27778.python-list@python.org> <7xsjii2qd7.fsf@ruckus.brouhaha.com> |
| NNTP-Posting-Host | 123.204.77.188 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Trace | posting.google.com 1328959079 17887 127.0.0.1 (11 Feb 2012 11:17:59 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Sat, 11 Feb 2012 11:17:59 +0000 (UTC) |
| In-Reply-To | <7xsjii2qd7.fsf@ruckus.brouhaha.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=123.204.77.188; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20220 |
Show key headers only | View raw
在 2012年2月11日星期六UTC+8上午7时57分56秒,Paul Rubin写道: > Righard van Roy > writes: > > I want to add an item to a list, except if the evaluation of that item > > results in an exception. > > This may be overkill and probably slow, but perhaps most in the spirit > that you're asking. > > from itertools import chain > > def r(x): > if x > 3: > raise(ValueError) > return x > > def maybe(func): > try: > yield func() > except: > return > I am wondering at which level to yield in a nested decorated function is more controllable. It is definitely wrong to yield in manny levels decorated. > def p(i): return maybe(lambda: r(i)) > > your_list = list(chain(p(1), p(5))) > print your_list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Postpone evaluation of argument Righard van Roy <pluijzer@gmail.com> - 2012-02-11 00:01 +0100
Re: Postpone evaluation of argument Paul Rubin <no.email@nospam.invalid> - 2012-02-10 15:57 -0800
Re: Postpone evaluation of argument 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-11 03:16 -0800
Re: Postpone evaluation of argument Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-02-11 10:54 +0200
csiph-web