Solved Keyword arguments everywhere? LILiamByteOP 13 Oct, 19:17 Should I always call functions with keyword arguments?
MAMateoG13 Oct, 21:18 Solutionreplies: 2Not always — for one or two obvious arguments, positional is fine (print(x), len(s)). Use keywords when there are several arguments of the same type that are easy to mix up, like rocket/pad or from/to. That's exactly this challenge's case.
SASamPrice15 Oct, 19:23You can even force keyword-only arguments with * in the signature: def transfer_cargo(cargo_id, *, from_module, to_module).
Comments 4
Join the discussion CommentAlready have an account? Log in
Not always — for one or two obvious arguments, positional is fine (
print(x),len(s)). Use keywords when there are several arguments of the same type that are easy to mix up, like rocket/pad or from/to. That's exactly this challenge's case.Same-type arguments → keywords. Got it.
That
*trick is great for APIs.You can even force keyword-only arguments with
*in the signature:def transfer_cargo(cargo_id, *, from_module, to_module).