Skip to content Skip to sidebar Skip to footer

Are Python Args And Kwargs Ever Named Something Else In Practice?

Python does not restrict the names of parameters, however some parameter names are strongly governed by convention, such as self, cls, args, and kwargs. The names self and cls alwa

Solution 1:

I don't see any reason against using context specific names, such as ...

my_sum(*numbers), my_parser(*strings, **flags), etc.

The print docs say *objects.

The zip docs say *iterables.

itertools.chain uses *iterables in the docs and in the docstring.

>>>from itertools import chain>>>chain.__doc__.splitlines()[0]
'chain(*iterables) --> chain object'

collections.ChainMap uses *maps in the docs and in __init__.

>>>from collections import ChainMap>>>from inspect import signature>>>signature(ChainMap.__init__)
<Signature (self, *maps)>

Feel free to hunt for more examples.

Post a Comment for "Are Python Args And Kwargs Ever Named Something Else In Practice?"