Bug or feature?

Alexey Nezhdanov snake at penza-gsm.ru
Thu Jan 15 00:40:36 EST 2004


Hello. Found a strange python behaivoir while writing some object. I've 
stripped out all other stuff so the problem is stright here:
=================================
#!/usr/bin/python

class Object:
     def __init__(self,val):
         self.val=val

     def Sub(self,delta):
         self.val-=delta
         return delta

c=Object(1)

### case 1 ###
d=c.Sub(1)
c.val+=d
print 'case A:',c.val

### case 2 ###
c.val+=c.Sub(1)
print 'case B:',c.val
=================================
Case 1 and case 2 prints out different calues (1 and 2 respectively).
Do not know - if this is a bug or feature of python.

--
Alexey Nezhdanov




More information about the Python-list mailing list