New syntax for blocks

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


On Nov 10, 9:44 pm, Terry Reedy <tjre... at udel.edu> 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(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))
>
> 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