On 28 Feb 2017, at 22:17, Victor Stinner wrote:

I just noticed a module on PyPI to implement this behaviour on Python functions:

   https://pypi.python.org/pypi/positional

Tangential to the main topic, but this module doesn’t enforce positional-only arguments. It allows you enforce keyword-only arguments like on Python 3:

        >>> from positional import positional
        >>> @positional(1)
        ... def replace(old, new):
        ...     ...
        ...
        >>> replace(old='a', new='b')
        >>> replace('a', 'b')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
          File “…/site-packages/positional/__init__.py", line 97, in inner
            raise TypeError(message)
        TypeError: replace takes at most 1 positional argument (2 given)

Frazer
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to