On Wed, Oct 9, 2013 at 12:20 PM, Eric Snow <ericsnowcurren...@gmail.com> wrote: > For me the allure of positional-only arguments lies in the following: > > 1. not having to roll my own *args handling; > 2. not having to clutter up my code with the *args handling; > 3. not having to handle positional-or-keyword params with *args when > also using positional-only args; > 4. documentation and help() can be more clear/accurate. > > [snip] > > Regarding help(), getting pydoc to make use of inspect.Signature > objects would be great. The idea of supporting optional groups in > inspect.Parameter sounds good to me and pydoc could make use of that.
It may work better to facilitate the syntax in this PEP through inspect.Signature and friends, rather than as a pseudo-addition to the Python syntax. Here is some additional API that could help: * inspect.Signature.from_string(sig) - a factory that parses a signature string (including "/" from this PEP or perhaps "<param>"). Could Argument Clinic make use of this directly? * inspect.Signature.__str__() - updated to also display "/" for positional-only (or the "<param>" syntax that RDM described). * inspect.MultiSignature - a Sequence(?) containing one or more Signature objects (proxies the first one), which facilitates grouping. * inspect.MultiSignature.from_string(sig) - a factory that parses a signature string (including the full syntax from this PEP), adding a Signature for each derivable signature. These, along with a few other additions, would certainly help address the 4 things I listed above. I have a rough implementation of the above APIs (ignore anything else :) [1]. -eric [1] https://bitbucket.org/ericsnowcurrently/odds_and_ends/src/default/signature.py _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com