__imul__ does not work !

Sean 'Shaleh' Perry shalehperry at attbi.com
Tue Oct 15 18:27:24 CEST 2002


On Tuesday 15 October 2002 08:58, Uwe Schmitt wrote:
> Hi,
>
> I tried to write a class which represents sets of natural numbers.
> I wanted to implement A *= B by defining __imul__ as below:
>

your code works under 2.2 here.

python /tmp/natural.py 
[0 1 1 0 0 1] 6
[0 1 0 1 0 1 0 1] 8
[0 1 1 0 0 1] 6
[0 1 0 0 0 1] 6
[0 1 1 0 0 1] 6
[0 1 0 0 0 1] 6

with test code:
a=NaturalNumberSet([1,2,5])
b=NaturalNumberSet([1,3,5,7])
print a.indices, a.length
print b.indices, b.length
b *= a
print a.indices, a.length
print b.indices, b.length
b.__imul__(a)
print a.indices, a.length
print b.indices, b.length




More information about the Python-list mailing list