class Foo:
def __init__(self, *args, **kwargs):
...
def some_method(self):
...
return something
I have this sample class. What I want to do, is when I create an instance it should instantly return the result of a particular method.
I know I can do this by Foo().some_method()
but is there anyway I can do this just creating a instance?
I tried doing this,
class Foo:
def __init__(self, *args, **kwargs):
...
return self.some_method()
def some_method(self):
...
return something
But it says TypeError: __init__() should return None, not 'object()'