Re: Python interpreter bug
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: Python interpreter bug

From: <alainpoint@yahoo.fr>
Date: Fri Oct 07 2005 - 15:32:32 CEST

There is definitely a bug.
Maybe the follownig snippet is more clear:
class OBJ:
        def __init__(self,identifier):
                self.id=identifier
                self.allocated=0
        #def __cmp__(self,other):
        # return cmp(other.allocated,self.allocated)
mylist=[OBJ(i) for i in range(10)]
excluded=[obj for obj in mylist if obj.id in [2,4,6,8]]
exclusion_list_by_id=[2,4,6,8]
print 'exclusion list by id=',exclusion_list_by_id
for obj in mylist:
        print 'current obj=',obj.id,
        if obj in excluded:
                print ' ---> THIS OBJECT IS EXCLUDED'
                assert obj.id in exclusion_list_by_id
                continue
        print

If you uncomment the two lines, the assert will be erroneously
triggered.
Alain
Received on Sat Oct 15 04:15:51 2005