A
Alexey Nezhdanov
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.
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.