i have register_users list that have list of user objects and every user object have password, username, email property i want to create a login function that get a **kwargs from input.
the kwargs input can be given to the function in 3 different ways.
kwargs may have 3 keys username, password and email.
kwargs may have 2 keys username or password.
kwargs may have email or password.
in all the above we must check whether there is a user object in the register_user list whose information is the same as the given input or not.
And the question I have is What is the best way to determine how kwargs input is given?and how to do this with minimum use of if, ifelse?or a pythonic way to do this.
class User:
def __init__(self, username, password, email):
self.username = username
self.email = email
self.password = password
user1 = User("user1", "user1@test.com", "test12345")
user2 = User("user2", "user2@test.com", "test12345")
register_users = [user1, user2]
def login(**kwargs):
pass # determine how kwargs is given to function and then check informations
login({"username": "user1", "email": "user1@test.com", "password": "test12345"})
login({"username": "user1", "password": "test12345"})
login({"email": "user1@test.com", "password": "test12345"})