class Foo:
def __init__(self, value):
return value
class Foo:
def __init__(self, value):
self.value = value
foo = Foo([1, 2, 3])
print(foo.value)
Explicit return in __init__
Used when the special class method __init__
has an explicit return value.
__init__
magic method is a basically constructor of an instance, so it should
constuct it but not return anything. The rest can be achieved through object
attributes like method, property, etc.