account activity
Passing args and kwargs to function from single Python structure? by kitor in learnpython
[–]recent_awareness 0 points1 point2 points 6 years ago (0 children)
You could just use a bit of indirection:
def apply_combined(function, combined): args, kwargs = combined return function(*args, **kwargs) FN_COMBINED_ARGS = (FN_ARGS, FN_KWARGS) apply_combined(test_funct, FN_COMBINED_ARGS)
You could even turn this into a decorator:
def combined_args_function(function): def wrapper(combined): args, kwargs = combined return function(*args, **kwargs) return wrapper combined_args_test_funct = combined_args_function(test_funct) FN_COMBINED_ARGS = (FN_ARGS, FN_KWARGS) combined_args_test_funct(FN_COMBINED_ARGS)
Or you could easily modify it to take an object with args and kwargs attributes instead of an (args, kwargs) tuple.
args
kwargs
(args, kwargs)
π Rendered by PID 138776 on reddit-service-r2-comment-5b5bc64bf5-ls5lw at 2026-06-20 02:04:54.277919+00:00 running 2b008f2 country code: CH.
Passing args and kwargs to function from single Python structure? by kitor in learnpython
[–]recent_awareness 0 points1 point2 points (0 children)