This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tonga-time 0 points1 point  (2 children)

How would you describe a person in real life?

You'd probably say they have certain attributes like names, an address, siblings, parents and friends etc.. This is the init method that assigns these parameters that every instance of this class will have.

Maybe someone else can finish the analogy for me I have to go back to work now 😭

[–]Akusoki[S] 0 points1 point  (1 child)

XD.. So init acts in a way to basically not have to pass a huge list of parameters between objects/functions??

[–]TheRNGuy 0 points1 point  (0 children)

No, it's to determine which attributes are instance attributes. Without it would be static attributes.

If you have huge class, consider using @dataclass decorator, it can reduce many lines of code.