Title: Add support of multiple signatures
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: larry, rhettinger, serhiy.storchaka, yselivanov
Priority: normal Keywords:

Created on 2017-01-23 10:26 by serhiy.storchaka, last changed 2017-01-23 17:51 by serhiy.storchaka.

Messages (3)
msg286068 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-23 10:26
Some functions can be described by the single signature. See examples in msg285647. Selected examples:

  dict.pop(key, default)

  type(name, bases, mapping)

  range(start, stop, step=1)

  min(iterable, *, key=identity)
  min(iterable, *, default, key=identity)
  min(*args, key=identity)

I think the only way to resolve this problem is to add the support of multiple signatures in inspect, pydoc, Argument Clinic, etc.
msg286101 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2017-01-23 17:09
Signature object provides methods like .bind(), which will be hard to define if a function has many signatures.  Also, inspect.signature currently returns one Signature object, that shouldn't be changed.

Wouldn't it be easier instead of this:
  type(name, bases, mapping)

do this:
  type(obj_or_name, bases=None, mapping=None)

And explain what really is going on in the docstring?
msg286104 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-23 17:51
It can be do, but I don't think it is worth. Making bases and mapping optional arguments does not make much sense to me. And there is no a value that can be used as a default value for the second parameter in dict.pop().
Date User Action Args
2017-01-23 17:51:01serhiy.storchakasetmessages: + msg286104
2017-01-23 17:09:18yselivanovsetmessages: + msg286101
2017-01-23 10:26:05serhiy.storchakacreate