Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] __repr__: to support pprint

Matthias welpboekewurm at gmail.com
Tue Feb 28 20:58:35 EST 2017


Hi,On 1 March 2017 at 02:18, qhlonline <qhlonline at 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.7Please note that unless this is still a problem in python 3, this isunlikely to be changed.__repr__ is (as per the docs) 'a printable string representation ofthe object'. If this were to get changed, many APIs might be brokendue 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, butit's potentially breaking a lot of code which interacts with otherprograms, and maybe even some internals.You are free to experiment with overriding/extending __repr__ for yourinternal usage, but please note that it might break external librariesdepending on obj.__repr__ or repr(obj), and print() might break whenusing built-in types as containers for your objects.I am a -1 on changing __repr__'s signature.-Matthias


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp