for with decimal values?

alex23 wuwei23 at gmail.com
Mon May 4 04:48:20 CEST 2009


On May 4, 11:41 am, Esmail <ebo... at hotmail.com> wrote:
> All this discussion makes me wonder if it would be a good idea
> for Python to have this feature (batteries included and all) - it
> would have its uses, no?

Well, sometimes more discussion == less consensus :)

But it's really easy to roll your own:

from decimal import Decimal

def args2dec(fn):
    '''*args to Decimal decorator'''
    float2dec = lambda f: Decimal(str(f))
    def _args2dec(*args):
        args = map(float2dec, args)
        return fn(*args)
    return _args2dec

@args2dec
def drange(start, stop, step):
    while start < stop:
        yield start
        start += step




More information about the Python-list mailing list