Tim Harig <user...@ilthio.net> writes:
> The fact that I bothered to create classes for the dice and roles, rather
> then simply iterating over a list of numbers,  should tell you that I
> produced was of a far more flexible nature; including the support for
> roles with dice having different numbers of sides.

    from itertools import product
    def n_sided_die(n): return xrange(1, n+1)

    # make one 3-sided die, one 4-sided die, and one 5-sided die
    dice = (n_sided_die(3), n_sided_die(4), n_sided_die(5))
    for roll in product(*dice):
        print roll

> I merely posted a simplied description of the dice-role objects
> because I thought that it demonstrated how exceptions can provide
> eligance of control for situations that don't involve what would
> traditionally be defined as an error.

Exceptions (though sometimes necessary) are messy and I'm having a hard
time trying to envision that code being cleaner with them than without
them.  If you post the actual code maybe that will help me understand.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to