3 ms·
The article has a couple of problems in my eyes: - "you might want to just copy-paste it and use it" ... that's maybe what people end up doing, but it's a terr
by diarrhea 6y ago
The article has a couple of problems in my eyes:
- "you might want to just copy-paste it and use it" ... that's maybe what people end up doing, but it's a terrible idea.
- The following `__repr__` is out of alignment with the output printed below it:
class Circle:
def __init__(self, x, y, radius):
self.x = x
self.y = y
self.radius = radius
def __repr__(self):
return f"Rectangle({self.x}, {self.y}, {self.radius})"
The class name is hardcoded; maybe use:
def __repr__(self):
name = self.__class__.__name__
return f"{name}({self.x}, {self.y}, {self.radius})"
- There's a bare `except` in the `traceback` demo. It is not a problem in this toy example and works, but bare `except` statements have no place in educational code. Some poor soul will copy-paste it and run into awful errors down the line (https://realpython.com/the-most-diabolical-python-antipattern/ https://realpython.com/the-most-diabolical-python-antipatter...)