New syntax for blocks

Carl Banks pavlovevidence at
Wed Nov 11 13:00:09 CET 2009

On Nov 10, 9:44 pm, Terry Reedy <tjre... at> wrote:
> Carl Banks wrote:
> > 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(
> > elif re.match(r'take\s+(\w+)',cmd) as m:
> >     hero.pick_up(
> > elif re.match(r'drop\s+(\w+)',cmd) as m:
> >     here.put_Down(
> The effect of this proposal can already be accomplished with a 'pocket'
> class

Nice metaphorical name.

> as has been posted before and again in a slightly different form
> in Steve's post.

I'm well aware of it, but I didn't think the proposal deserved to be
called stupid when it was a reasonable solution to a real need, even
though a workable and less intrusive option exists.

Carl Banks

More information about the Python-list mailing list