Lets say I have a class like below:
Class Foo:
x: int
y: List[int]
z: int = 5
def __init__(self, x:int, z: int = 5):
self.x = x
self.y = []
self.z = z
### some other methods
My questions are;
If I am using the types inside the init function, isn't me using types at the class level become redundant?
I want the variable y to be initialized to an empty list for each instance. So, I didn't write the below code as it initialized the y at the class level. Is my understanding correct?
Class Foo: x: int y: List[int] = [] z: int = 5 def __init__(self, x:int, z: int = 5): self.x = x self.z = z
I'm trying to improve my code quality, so if I am missing some primary understanding regarding it, please let me know.
Thank you in advance.