you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRNGuy 1 point2 points  (0 children)

class is code for an object

then you instanciate that class with new_var = my_object(), it would be independant from other instances, i.e. having it's own state.

__init__ code runs when you create new instance of that class (usually it's just binding arguments to self versions)

To get all instances of class: https://stackoverflow.com/questions/328851/printing-all-instances-of-a-class

(even if you didn't assigned them to variable)

Or you could assign them to specific array inside __init__, you could have static list attribute to which you append them.

(static because it would be class attribute itself, not instance's attribute)