Question: I have a class where I would like to instantiate the object in several ways depending on the arguments. When I pass a filepath to the function `__init__` it should restore all parameters from the object saved as a pickle file. Is there any smart way to do so, something like `self=load(...)`

Answer: 
As stated in another answer, `self = load(...)` only replaces the local variable `self`. The same answer recommends resorting to the `__new__` method of the class which works but isn't a good practice in python, as overriding this method should be used for immutable types only.

Instead, you should be using a [factory](https://en.wikipedia.org/wiki/Factory_(object-oriented_programming)), which can in this case be a simple function :

```
def foo_factory(filename=None, *args, **kwargs):
    if filename:
        foo_factory.foo = pickle.load(filename)
    else:
        foo_factory.foo = Foo(*args, **kwargs)
    return foo_factory.foo

```

where we supposed that class `Foo` is the class of interest.

(see [Why is \_\_init\_\_() always called after \_\_new\_\_()?](https://stackoverflow.com/questions/674304/why-is-init-always-called-after-new) for more details and references)
This is probably not a "smart way" but if you prefer a third option (besides **new** and factory):

```
class myclass:

  def __init__(self, filename):

    with open(filename, 'rb') as f:
      myinstance = pickle.load(f)

    for k in myinstance.__dict__.keys():
      setattr(self, k, getattr(myinstance, k))

```

This loops through all properties of the loaded instance (myinstance) and sets the corresponding ones in the instance that is initialized (self).