In Python, if I have a class
like
class Rectangle:
x:int = 0
y:int = 0
width:int = 0
height:int = 0
Is there a way to create an instance of it and setting all attributes all at once without a constructor?
Something like (obviously not working) :
rect = Reactangle() { x = 0, y = 0, width = 20, height = 30 }
I am aware of dictionaries, so I'm open to suggestions.
Edit
I am aware that I could do
class Rectangle:
def __init__(x:int = 0, y:int = 0, width:int = 0, height:int = 0):
self.x = x
self.y = y
self.width = width
self.height = height
But that's not really a nice looking solution, with all the repetitions, when the class contains a dozen attributes, etc.
As read in the comments, it looks like dataclasses is the way to go.