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

tjr

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to