What does the *
mean in the following code (found in the pprint
library)?
def pformat(object, indent=1, width=80, depth=None, *, compact=False):
"""Format a Python object into a pretty-printed representation."""
return PrettyPrinter(indent=indent, width=width, depth=depth,
compact=compact).pformat(object)
If it was *args
then it would be an arbitrary number of positional parameters. The parameter values would be in the tuple called args
. The first 4 parameters could be assigned either by name or by position, the parameter compact
could only be assigned by name...
Well, NO! Because it doesn't agree with the documentation:
In a function call, keyword arguments must follow positional arguments.
So, what does the star do after and before other named arguments? And how is that used? Or why is it there if it is not used?