Confused again
Duncan Smith
buzzard at urubu.freeserve.co.uk
Sun Feb 23 21:20:32 EST 2003
I'm still (again) having a little trouble with operator overloading. I
changed the original code I posted yesterday (Confusing problem) so that it
now (apparently) does what I want. I simply changed "def __cmp__(self,
other):" to "def __eq__(self, other):". But if I try to raise an exception
after calling the function, the exception is apparently ignored. eg. the
following code snippet,
print table == numtable2
if table == numtable2:
to_remove.append(table)
else:
print 'what?'
raise Error
class Error:
pass
>>> c.clusters[(3,)].pruneTables()
0 # evaluates to false as expected
what? # prints 'what?' OK
>>> # but no error
I know this will be something I should know, or should have figured out for
myself. But I just don't see it. Any help appreciated. Cheers.
Duncan
More information about the Python-list
mailing list