Using a classmethod instead of __init__ for object creation?

In a codebase I’m working on, the previous authors used this pattern of using a new() classmethod to create objects instead of __init__(). The __init__() methods are all very short and just set some default values while new() does the heavy lifting. This confuses me though because as far as I can tell, all the logic and work going on in new() would be right at home in __init__().

When would this

class Foo:
    def new(cls, spam, eggs):
        foo = Foo()
        foo._bar =, eggs)

        return foo

    def __init__(self):
        self._bar = None

be preferable to this?

class Foo:
    def __init__(self, spam, eggs):
        self._bar = Spam(spam, eggs)

Is this a pattern that anyone has seen before?

Looks to me like somebody is programming JavaScript in Python. Using __init__ is the proper way to do it.

1 Like