[Python-Dev] A future division proposal

Skip Montanaro skip@pobox.com (Skip Montanaro)
Wed, 25 Jul 2001 12:48:51 -0500


    Paul> Actually, when I tried, I got into a bit of a mess getting the
    Paul> type checks (which you need) right -

    Paul>     def olddiv(n,m):
    Paul>         if type(n) == type(m) == type(0):
    Paul>             return n//m
    Paul>         else:
    Paul>             return n/m

    Paul> But this needs the checks expanded to take longs into
    Paul> account. Which is where it gets messy.

Wouldn't this work for ints and longs?

    def olddiv(n,m):
        ints = [type(0), type(0L)]
        if type(n) in ints and type(m) in ints:
            return n//m
        else:
            return n/m

-- 
Skip Montanaro (skip@pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/