Comparison with False - something I don't understand

Paul Rubin no.email at nospam.invalid
Sun Dec 5 04:18:22 EST 2010


Tim Harig <usernet at 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.



More information about the Python-list mailing list