3 ms·
Hm, where is the large advantage over building a list pos_args and a map kw_args and calling func(*pos_args, **kw_args)? You can also transform between both for
by tetha 3y ago
Hm, where is the large advantage over building a list pos_args and a map kw_args and calling func(*pos_args, **kw_args)? You can also transform between both forms with a few comprehensions with a few isinstance-checks.
>>> def foo(a, b, c=42, d=23):
... print(a, b, c, d)
...
>>> args = ['a-value', 'b-value']
>>> kwargs = { 'c': 'c-value', 'd': 'd-value' }
>>> foo(*args, **kwargs)
a-value b-value c-value d-value
- kstrauser 3y agoI think you're right. Or if you have functions you'd want to use this more often than never, I'd strongly prefer to make them kwarg-only (ie `def foo(*, arg1, arg2, ...)`). Then you don't have to care about ordering at all.
- wheelerof4te 3y agoThere is none. But let's get another hack in, why not. /s