You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a standard way for the docstring to tell the user that the arguments (or following arguments) are keyword only? Other than some note for each argument? I mean for a situation like this:
defmy_func(a, *, b, c):
""" My function does stuff a : object Something about `a`. b : object, keyword-only Something about `b`. c : object, keyword-only Something about `c`. """print(a, b, c)
The text was updated successfully, but these errors were encountered:
There's no standard way to do this. There's optional which needs to be kept unchanged (because it's so widely used, not necessarily because it's optimal), and that intersects with keyword-only. The description for d here is a little ugly, but I don't have a better suggestion:
defmy_func(a, *, b, c, d=None):
""" My function does stuff a : object Something about `a`. b : object, keyword-only Something about `b`. c : object, keyword-only Something about `c`. d : object, optional, keyword-only """
Personal opinion: keyword-only (and positional-only) are just syntactic usage aspects. They don't carry information for understanding the function and its parameters. I therefore propose that it's sufficient to let the user infer the usage from the signature and would not document that aspect in the parameters section at all.
Is there a standard way for the docstring to tell the user that the arguments (or following arguments) are keyword only? Other than some note for each argument? I mean for a situation like this:
The text was updated successfully, but these errors were encountered: