It Runs Perfectly, Gives Error when you Debug
For Python --> Module 7: Object Oriented Programming --> Class & Static Methods, the examples are interesting. When I run them both, they give the results shown. But when I debug them, they actually give me an error. Example for Class Methods class Rectangle: def __init__(self, width, height): self.width = width self.height = height def calculate_area(self): return self.width * self.height @classmethod def new_square(cls, side_length): return cls(side_length, side_length) square = Rectangle.new_square(5) print(square.calculate_area()) Example for Static Methods: class Pizza: def __init__(self, toppings): self.toppings = toppings @staticmethod def validate_topping(topping): if topping == "pineapple": raise ValueError("No pineapples!") else: return True ingredients = ["cheese", "onions", "spam"] if all(Pizza.validate_topping(i) for i in ingredients): pizza = Pizza(ingredients) When I run the Class Method code, it gives me 25 as usual, but this is not the case in debugging. The error it gives is really various based on the IDE. For Thonny, it gives AttributeError: 'CustomStackFrame' object has no attribute 'node_tags'. For Python IDLE, it gives a different kind of error: Invalid Character in Identifier Can someone please explain if the program is right, or if it is wrong?