Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ImprovedPartial(object): # pylint: disable=useless-object-inheritance
- __slots__ = ['_call', '_args', '_kwargs']
- def __init__(self, call, *args, **kwargs):
- self._call = call
- self._args = args
- self._kwargs = kwargs
- def __call__(self, *args, **kwargs):
- in_args = list(args)
- built_args = [(arg if arg is not ... else in_args.pop(0))
- for arg in self._args] + in_args
- return self._call(*built_args, **ChainMap(self._kwargs, kwargs))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement