Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Serhiy Storchaka
On 01.03.17 16:35, Paul Moore wrote: On 1 March 2017 at 13:50, Steven D'Aprano wrote: It is possible that we could come up with a pretty-printing protocol, but that wouldn't be a trivial job. I'd be inclined to do this via simplegeneric. Let pprint do what it currently does, but allow users t

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Paul Moore
On 1 March 2017 at 14:48, Eric V. Smith wrote: > > If you mean functools.singledispatch, then I agree. It's even mentioned as a > motivating case in PEP 443. Sorry - that was a thinko on my part - yes, functools.singledispatch. Paul ___ Python-ideas m

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Eric V. Smith
> On Mar 1, 2017, at 9:35 AM, Paul Moore wrote: > >> On 1 March 2017 at 13:50, Steven D'Aprano wrote: >> It is possible that we could come up with a pretty-printing protocol, >> but that wouldn't be a trivial job. > > I'd be inclined to do this via simplegeneric. Let pprint do what it > current

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Paul Moore
On 1 March 2017 at 13:50, Steven D'Aprano wrote: > It is possible that we could come up with a pretty-printing protocol, > but that wouldn't be a trivial job. I'd be inclined to do this via simplegeneric. Let pprint do what it currently does, but allow users to register implementations for specif

Re: [Python-ideas] __repr__: to support pprint

2017-03-01 Thread Steven D'Aprano
On Wed, Mar 01, 2017 at 01:04:00PM +1100, Chris Angelico wrote: > On Wed, Mar 1, 2017 at 12:58 PM, Matthias welp wrote: > > 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_

Re: [Python-ideas] __repr__: to support pprint

2017-02-28 Thread 语言破碎处
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" wr

Re: [Python-ideas] __repr__: to support pprint

2017-02-28 Thread Chris Angelico
On Wed, Mar 1, 2017 at 12:58 PM, Matthias welp wrote: > 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 c

Re: [Python-ideas] __repr__: to support pprint

2017-02-28 Thread Matthias welp
Hi, On 1 March 2017 at 02:18, qhlonline 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

Re: [Python-ideas] __repr__: to support pprint

2017-02-28 Thread qhlonline
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 Regards! At 2017-03-01 06:59:52, "语言破碎处" wrote: Hi, everyone! Oftenly, __repr__ return

Re: [Python-ideas] __repr__: to support pprint

2017-02-28 Thread Steven D'Aprano
On Wed, Mar 01, 2017 at 06:59:52AM +0800, 语言破碎处 wrote: > solution: > allow __repr__ to return > str > OR tuple: (args, kws) > > Better, isn't it? No. -- Steve ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailma

[Python-ideas] __repr__: to support pprint

2017-02-28 Thread 语言破碎处
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 div