Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #32079
| Date | 2012-10-25 09:58 +1100 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: while expression feature proposal |
| References | <7x625zo5su.fsf@ruckus.brouhaha.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2805.1351119493.27098.python-list@python.org> (permalink) |
On 24Oct2012 15:37, Paul Rubin <no.email@nospam.invalid> wrote: | Cameron Simpson <cs@zip.com.au> writes: | > if re_FUNKYPATTERN.match(test_string) as m: | > do stuff with the results of the match, using "m" | | class memo: | def __call__(f, *args, **kw): | self.result = f(*args, **kw) | | m = memo() | if result(re_FUNKYPATTERN.match, test_string): | do stuff with the results of the match, | using "m.result" | | then | | if re_CONSTRUCT1.match(line) as m: | ... handle construct 1 ... | elif re_CONSTRUCT2.match(line) as m: | ... handle construct 2 ... | elif re_CONSTRUCT3.match(line) as m: | | becomes | | if m(re_CONSTRUCT1.match, line): | .. handle construct 1 ... | elif m(re_CONSTRUCT2.match, line): | .. handle construct 2 ... Cute. Not sure I like it, but cute:-) -- Cameron Simpson <cs@zip.com.au> If you do not read the paper, you are uninformed. If you do read the paper, you are misinformed. - Mark Twain
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: while expression feature proposal Cameron Simpson <cs@zip.com.au> - 2012-10-25 09:26 +1100
Re: while expression feature proposal Paul Rubin <no.email@nospam.invalid> - 2012-10-24 15:37 -0700
Re: while expression feature proposal Paul Rubin <no.email@nospam.invalid> - 2012-10-24 15:47 -0700
Re: while expression feature proposal Cameron Simpson <cs@zip.com.au> - 2012-10-25 09:58 +1100
Re: while expression feature proposal Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-10-25 11:44 +0200
Re: while expression feature proposal Grant Edwards <invalid@invalid.invalid> - 2012-10-25 14:15 +0000
Re: while expression feature proposal Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-10-25 18:15 +0200
csiph-web