- #1
Zap
- 406
- 120
- TL;DR Summary
- Weird Bug in Python
I've encountered this really weird bug in Python. Below is a snippet from a class method. The error occurs where I've placed the two print statements. The update method has absolutely nothing to do with Cprev. The update function changes the value of the attribute self.C. However, the two print statements (1 and 2) print different values for Cprev. For whatever reason, the changes made to self.C by the update method are also made for Cprev, though this is nowhere explicitly defined.
Python:
def classify( self : object ) -> None :
Cprev = np.empty( self.C.shape )
while np.not_equal( Cprev, self.C ) :
Cprev = self.C
print( 1, Cprev )
self.__update()
print( 2, Cprev )
return
Last edited: