math module for Decimals

Mark Dickinson dickinsm at
Sun Jan 4 11:56:01 CET 2009

On Jan 4, 10:38 am, "alex goretoy" <aleksandr.gore... at>
> haha python-svn # python Lib/
>   File "Lib/", line 683
>     sign = 0 if _math.copysign(1.0, f) == 1.0 else 1
>               ^
> SyntaxError: invalid syntax
> Although, It may be only because I ran it through python 2.4.3

Ah yes, that's it:  the 'x if b else y' syntax wasn't
introduced until Python 2.5;  see

for more.

Hmm.  Maybe we shouldn't be using this syntax in from_float, if it's
the only thing that prevents the trunk version of from
being used with Python 2.4.  On the other hand, from_float isn't
going to work until 2.7 anyway, since it uses a whole bunch of
new stuff:  as_integer_ratio and copysign (both introduced in 2.6),
and bit_length (introduced in 2.7).


More information about the Python-list mailing list