I have following class and a function defined in it.
class utils:
def pass_hash(unhashed):
hashed = hashlib.sha256(unhashed)
hashed = hashed.hexdigest()
return hashed
When I call
print(utils.pass_hash('abc'.encode()))
it works fine but if i call
obj = utils()
print(obj.pass_hash('abc'.encode()))
it gives following error:
print(obj.pass_hash('abc'.encode()))
TypeError: pass_hash() takes 1 positional argument but 2 were given
Whereas if I pass self argument in function then this bheaviour gets reversed i.e. it works fine with object but on accesing like utils.pass_hash() it gives error.
Can someone please exlain this behaviour?