Doubts about the Design of python Class

I am a beginner in python . I think of some questions when practicing the code, as follows:

there is now a User class that abstractly represents each user , and can have some attributes, such as this:

class UserModel:
    def __init__(self)
        self.users = []
    
    def all(self):
        return self.users
        

method 2: proceed directly on the User class, as shown by using classmethod , for example:

class User:
    def __init__(self, form):
        self.name = form.get("name", "")
        self.password = form.get("password", "")
    
    @classmethod
    def all(cls):
        users = [cls(form) for form in forms]
        return users

both methods can achieve the same function. Which method is better, or is there a better way to implement it? I would appreciate it if you could answer it.


I think I can register the instance in a class variable in _ _ new__

class User:
    users = []
    def __new__(cls, *args, **kwargs):
        instance = super().__new__(cls, *args, **kwargs)
        cls.users.append(instance)
        return instance
print(User.users)
Menu