New syntax for blocks

Terry Reedy tjreedy at
Wed Nov 11 06:44:55 CET 2009

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 as has been posted before and again in a slightly different form 
in Steve's post.


More information about the Python-list mailing list