fixedpoint cmp conundrum

Aahz aahz at pythoncraft.com
Mon May 3 22:48:23 EDT 2004


[BTW, please try to avoid using quoted-printable if at all possible]

In article <mailman.220.1083626744.25742.python-list at python.org>,
Robert Brewer <fumanchu at amor.org> wrote:
>
>>>> a = fixedpoint.FixedPoint(3, 2)
>>>> bunch = [None, 12, a]
>>>> bunch.index(a)
>Traceback (most recent call last):
>  File "<interactive input>", line 1, in ?
>  File "C:\Python23\Lib\fixedpoint.py", line 316, in __cmp__
>    xn, yn, p = _norm(self, other, FixedPoint=type(self))
>  File "C:\Python23\Lib\fixedpoint.py", line 482, in _norm
>    y = FixedPoint(y, x.p)
>  File "C:\Python23\Lib\fixedpoint.py", line 255, in __init__
>    raise TypeError("can't convert to FixedPoint: " + `value`)
>TypeError: can't convert to FixedPoint: None
>
>Mmrph! I could fix this by:
>
>1. Iterating through "bunch" by hand and trapping TypeError,
>2. Overriding or hacking the __cmp__ function in fixedpoint, or
>3. Overriding or hacking the _norm function in fixedpoint
>
>The question is: given that there are multiple places to "fix" this,
>where should I do so?

http://fixedpoint.sourceforge.net/
with a patch using option 2.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Adopt A Process -- stop killing all your children!



More information about the Python-list mailing list