Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Tim Peters
[David Mertz] > I often use doctests to verify APIs and behaviors when I update code. I > > know I'm in a minority and most developers slightly disparage doctests. [Steven D'Aprano] > I don't know why you think that "most developers" disparage doctests. > Perhaps they're the same ones who

Re: [Python-ideas] Idea: Deferred Default Arguments?

2018-07-27 Thread Robert Vanden Eynde
> Someone wrote : > Thank you for your deferred default values idea, which we're now working on together. > https://github.com/petered/peters_example_code/blob/master/peters_example_code/deferral.py Allowing to write: from deferral import deferrable_args, deferred @deferrable_args def f(x, y=2,

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Robert Vanden Eynde
This is a functionality I sometimes need. Maybe you can do a pull request to more-itertools and that would be the end of it? I don't know if that's general enough for being added to the standard library, more-itertools seems the way to go for me. Go find out if raising a ValueError suits their

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread David Mertz
I have never wanted this behavior myself. So that's 0% of the time for me. I happily believe that Peter O'Connor wants it 90% of the time... although I guess it suggests he probably organizes his algorithms differently than I do at some broader level. For my needs, zip() is common, and

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Steven D'Aprano
On Fri, Jul 27, 2018 at 07:02:37PM +0200, Peter O'Connor wrote: > I find that about 90% of the time I want want to zip iterators together, I > expect them to be the same length and want to throw an exception if they > aren't. Yet there is not currently a solution for this in the standard >

Re: [Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Jonathan Fine
Hi Peter Thank you for your deferred default values idea, which we're now working on together. https://github.com/petered/peters_example_code/blob/master/peters_example_code/deferral.py You wrote: > I find that about 90% of the time I want want to zip iterators together, I > expect them to be

[Python-ideas] Can we add "zip and assert equal length" to the standard library?

2018-07-27 Thread Peter O'Connor
I find that about 90% of the time I want want to zip iterators together, I expect them to be the same length and want to throw an exception if they aren't. Yet there is not currently a solution for this in the standard library for this, and as a result I always have to take this function

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Chris Angelico
On Fri, Jul 27, 2018 at 9:24 PM, Serhiy Storchaka wrote: > 27.07.18 12:53, Chris Angelico пише: > > from collections import OrderedDict > od = OrderedDict([('a', 1), ('b', 2)]) > dict.__repr__(od) >> >> "{'a': 1, 'b': 2}" > > > dict.__repr__() can output items in wrong order. >

Re: [Python-ideas] PEP 505: None-aware operators

2018-07-27 Thread Rhodri James
On 26/07/18 22:28, Abe Dillon wrote: The readability issue isn't just a matter of a new set of symbols to learn. It isn't even that the symbols are used in a non-intuitive way (though that doesn't help). We could argue about how intuitive or not these operators are, but they are used in other

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread David Mertz
On Fri, Jul 27, 2018, 1:23 AM Steven D'Aprano wrote: > On Thu, Jul 26, 2018 at 06:50:20PM -0400, David Mertz wrote: > > I often use doctests to verify APIs and behaviors when I update code. I > > know I'm in a minority and most developers slightly disparage doctests. > > I don't know why you

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Serhiy Storchaka
27.07.18 12:53, Chris Angelico пише: from collections import OrderedDict od = OrderedDict([('a', 1), ('b', 2)]) dict.__repr__(od) "{'a': 1, 'b': 2}" dict.__repr__() can output items in wrong order. >>> from collections import OrderedDict >>> od = OrderedDict([('a', 1), ('b', 2)]) >>>

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Robert Vanden Eynde
Sorry Steven I didn't see your clever dict.__repr__ solution that Chris pointed out too. That's what I was looking for ^^ And now for pprint, apparently that doesn't seem difficult to implement. About the part where "the representation looses the type information", pformat(od) could be

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Terry Reedy
On 7/26/2018 1:23 PM, Terry Reedy wrote: On 7/26/2018 1:21 PM, Terry Reedy wrote: On python-idea,  Miro Hrončok asked today whether we can change the OrderedDict repr from, for instance, OrderedDict([('a', '1'), ('b', '2')]) # to OrderedDict({'a': '1', 'b': '2'}) I am not sure what our repr

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Chris Angelico
On Fri, Jul 27, 2018 at 7:45 PM, Thomas Jollans wrote: > On 27/07/18 08:06, Robert Vanden Eynde wrote: > > Thanks for your response, I want to print/repr an OrderedDict() without > relying on the fact that "dict are ordered" ie. I want a solution < python > 3.7. > Currently, if I do repr(

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Thomas Jollans
On 27/07/18 08:06, Robert Vanden Eynde wrote: Thanks for your response, I want to print/repr an OrderedDict() without relying on the fact that "dict are ordered" ie. I want a solution < python 3.7. Currently, if I do repr( OrderedDict([(1,2),(3,4)]) ), I get the string

Re: [Python-ideas] Add function readbyte to asyncio.StreamReader

2018-07-27 Thread Jörn Heissler
On Mon, Jul 23, 2018 at 22:25:14 +0100, Gustavo Carneiro wrote: > Well, even if it is worth, i.e. your use case is not rare enough, Reading a single byte is certainly a special case, but I think it's generic enough to warrant its own function. I believe there should be many binary protocols out

Re: [Python-ideas] As-do statements/anonymous blocks in python

2018-07-27 Thread Steven D'Aprano
I *think* you are trying to find a syntax for "code blocks" like Ruby has, but I'm not sure. Your examples are a little confusing to me (possibly because you have at least three separate suggestions here, "as" blocks, a mysterious "do" keyword I don't understand, and partial application using %

Re: [Python-ideas] Change repr of collections.OrderedDict to be more dict-like

2018-07-27 Thread Robert Vanden Eynde
Thanks for your response, I want to print/repr an OrderedDict() without relying on the fact that "dict are ordered" ie. I want a solution < python 3.7. Currently, if I do repr( OrderedDict([(1,2),(3,4)]) ), I get the string "OrderedDict([(1,2),(3,4)])", I'd like a function that would return the