I am practicing writing objects, and I wanted to print parts of my code out to see how the object changes, and I keep getting TypeError: 'int' object is not callable, for str(). I checked and string is treated as a class object, but this is the entirety of my code, when I try to go to the definition for str(), it links me the builtins.pyi file I think for pylance in vscode. What is happening here?
class Rectangle():
def __init__(self, length, width):
self.length = length
self.width = width
def area(self):
return self.length * self.width
def perimeter(self):
return self.length * 2 + self.width * 2
def __dir__(self):
return ['width','length','area', 'perimeter']
class Square(Rectangle):
def __init__(self, length):
self.length = length
self.width = length
def printAttr(object):
print(object.__dict__)
for i in dir(object):
print(i + ": " + str(eval("object."+i+'()')))
printAttr(Rectangle(2,4))