March 9th, 2003, 06:19 PM
TypeError for int with read-only attributes?
Hullo, I've got some code that keeps putting out the following error:
self.track.size is assigned as a string object, and is later copied to be an int object when I need it as an int. I can't see why it wouldn't be mutable, so why do I keep getting this error
Traceback (most recent call last):
File "./quickrip.py", line 174, in updateTrack
self.track.size = self.fileSize.text()
TypeError: 'int' object has only read-only attributes (assign to .size)
March 9th, 2003, 08:12 PM
Er, because you can't modify the size of an int. They are pretty much one size fits all If you need to alter the behavior of something based on the type of the variable, use the type() function to do type-checking first and then act accordingly.