Is there any function in python standard library that returns its argument, something similar to lambda x: x
and a method that returns its self?
My motivation is to implement something like:
def identity(x):
return x
def default(arg, default, func=identity):
return func(arg) if arg is not None else func(default)
Ruby has itself
that would be something like:
class Self:
def itself(self):
return self
There are other use cases for a function/method composition that returns its arguments or its self.