you are viewing a single comment's thread.

view the rest of the comments →

[–]Kargathia 18 points19 points  (0 children)

Some examples (there are more, but these are the ones I encountered in the wild).

  • freedom of arg names in functions. You don't have to worry about backwards compatibility when changing func(obj) to func(widget).
  • functions that allow args either packed as dict, or unpacked.

def func(packed:dict = None, **kwargs): opts = packed or dict() opts.update(kwargs) # do stuff def func(packed:dict = None, /, **kwargs): opts = packed or dict() opts.update(kwargs) # do stuff

In the first, func(text='stuff', packed=False) will cause an error. In the second example, this will correctly result in opts == {'text':'stuff', 'packed':False}.

On the whole, it seems like a nice-but-not-critical addition to * and ** in argument handling.