Perl is worse!

Alex Martelli alex at magenta.com
Sun Jul 30 10:37:40 EDT 2000


"Eric Lorenzo" <zo at angband.org> wrote in message
news:3h7la4bz5j.fsf at angband.org...
    [snip]
> def parse_die(s):
>     try:
>         g = parse_die_re.match(s).groups()
>     except AttributeError:
>         raise ValueError('Not a valid die expression')
>     return int(g[0]), int(g[1]), int(g[2] or 0)

I think it may be slightly preferable to express this as:

     try:
         g = parse_die_re.match(s).groups(0)
     except AttributeError:
         raise ValueError('Not a valid die expression')
     return map(int, g)


Alex






More information about the Python-list mailing list