[Python-ideas] __repr__: to support pprint

语言破碎处 mlet_it_bew at 126.com
Tue Feb 28 17:59:52 EST 2017


Hi, everyone!
Oftenly, __repr__ return "{type}({args}, {kws})"
problem:
    1) to call .format() myself is tedious
        I have seen someone do it wrong: "T(1,)"!
        I write a helper function myself,
            but to import such tiny function everywhere isnot good.
    2) pprint cannot dive into string that from repr()
        To use pprint, I sometimes have to recursively
            turn objects into builtin containers:
            (type_name, args...)

solution:
allow __repr__ to return
    str
    OR tuple: (args, kws)


Better, isn't it?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170301/b38c77d1/attachment.html>


More information about the Python-ideas mailing list