Possible Duplicate:
what is difference between init and call in python?
I'm trying to create a callable class which will take arguments, then return itself as an object.
class User(object):
def __init__(self, loginName, password):
self.loginName = loginName
def __call__(self):
if self.login():
return self
return None
def login(self):
database = db.connection
realUser = database.checkPassWord(self.loginName, self.password)
return realUser
My questions are, if I call this object like so:
newUserObject = User(submittedLoginName)
Will __init__
get called BEFORE __call__
? Should __init__
get the argument or should I be moving the argument over to __call__
like
def __call__(self, loginName):