gmpy and counting None
robert.kern at gmail.com
Tue Oct 14 00:16:57 CEST 2008
> On Oct 13, 2:43 pm, <mma... at gmx.net> wrote:
>> I just stumbled upon the following issue (I am running Debian):
>> $ python
>> Python 2.5.2 (r252:60911, Sep 29 2008, 21:15:13)
>> [GCC 4.3.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.>>> [2, None].count(None)
>>>>> from gmpy import mpz
>>>>> [mpz(2), None].count(None)
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> TypeError: coercion to gmpy.mpz type failed
>> Is this a bug in gmpy?
> Does the underlying GMP code support Nulls?
I don't think it has to. Probably, it just should implement __ne__ to return
False if it cannot coerce. Of course, the codebase is relatively old, so it may
still be using __cmp__ and __coerce__. That would make things more difficult.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list