It has not to break current code: def repr(obj, allowed_tuple = False): r = type(obj).__repr__() if allowed_tuple: return r if isinstance(r, tuple): r = make_str(type(obj), r) return r
At 2017-03-01 09:58:35, "Matthias welp" <boekew...@gmail.com> wrote: >Hi, > >On 1 March 2017 at 02:18, qhlonline <qhlonl...@163.com> wrote: >> Yes, We are both python users with languages OTHER then English, It is a >> headache when looking at the print output of dicts with other language >> encoding. They are just byte array. I am using python2.7 > >Please note that unless this is still a problem in python 3, this is >unlikely to be changed. > >__repr__ is (as per the docs) 'a printable string representation of >the object'. If this were to get changed, many APIs might be broken >due to tuples not having the same methods and/or features as strings, >e.g. you cannot use them as a path. Not saying that they will, but >it's potentially breaking a lot of code which interacts with other >programs, and maybe even some internals. > >You are free to experiment with overriding/extending __repr__ for your >internal usage, but please note that it might break external libraries >depending on obj.__repr__ or repr(obj), and print() might break when >using built-in types as containers for your objects. > >I am a -1 on changing __repr__'s signature. > >-Matthias
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/