New syntax for blocks
pavlovevidence at gmail.com
Wed Nov 11 12:52:45 CET 2009
On Nov 10, 9:37 pm, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
> On Tue, 10 Nov 2009 20:13:21 -0800, Carl Banks wrote:
> > On Nov 10, 7:12 pm, Steven D'Aprano
> > <ste... at REMOVE.THIS.cybersource.com.au> wrote:
> >> On Tue, 10 Nov 2009 12:45:13 -0800, Bearophile wrote:
> >> > r:
> >> >> i think the following syntax would be quite beneficial to replace
> >> >> some redundant "if's" in python code.
> >> >http://python.org/dev/peps/pep-3003/
> >> I knew it wouldn't take long for people to start responding to any
> >> proposal with "don't bother, there's a moratorium".
> >> Of course in this case, the correct response would have been "don't
> >> bother, it's a stupid idea, moratorium or no moratorium".
> > r didn't actually give a good example. Here is case where it's actually
> > useful. (Pretend the regexps are too complicated to be parsed with
> > string method.)
> > if re.match(r'go\s+(north|south|east|west)',cmd) as m:
> > hero.move(m.group(1))
> > elif re.match(r'take\s+(\w+)',cmd) as m:
> > hero.pick_up(m.group(1))
> > elif re.match(r'drop\s+(\w+)',cmd) as m:
> > here.put_Down(m.group(1))
> This is where a helper function is good. You want a dispatcher:
No I really don't. I want to be able to see the action performed
adjacent to the test, and not have to scroll up to down ten pages to
find whatever function it dispatched to.
More information about the Python-list