[issue16801] Preserve original representation for integers / floats in docstrings

Serhiy Storchaka report at bugs.python.org
Sat Dec 29 17:38:54 CET 2012


Serhiy Storchaka added the comment:

> And if os.open were supplied in os.py:
>
>     @inspect.override_string_representation('mode',
>         'os.O_CREAT | os.O_RDWR')
>     def open(file, flags, mode=0o777, *, dir_fd=None):

Other use case is a sentinel default. "foo(arg={})" looks better than "foo(arg=<object object>)" for function which use a sentinel idiom:

    _sentinel = object()
    def foo(arg=_sentinel):
        if arg is _sentinel:
            arg = {}
        ...

Sometimes full signature overwriting is needed (see for example Python implementation of operator.methodcaller() in issue16694).

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16801>
_______________________________________


More information about the Python-bugs-list mailing list