Re: [Python-ideas] kw to be ordered dict

2016-09-05 Thread INADA Naoki
And there is a patch already. http://bugs.python.org/issue27350 On Mon, Sep 5, 2016 at 5:32 AM, Riley Banks wrote: > This has been discussed before. See for example > https://mail.python.org/pipermail/python-ideas/2010-October/008445.html > > There's even PEP about this: https://www.python.org/d

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread Ivan Levkivskyi
On 4 September 2016 at 01:31, Yury Selivanov wrote: > Below is a proposal to add support for asynchronous comprehensions and > asynchronous generator expressions in Python 3.6. > Interesting proposal. Would be nice to have this! I have one question: > ``await`` in Comprehensions > ---

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread Sven R. Kunze
Hi Yury, just for my understanding: On 04.09.2016 01:31, Yury Selivanov wrote: We propose to allow the use of ``await`` expressions in both asynchronous and synchronous comprehensions:: result = [await fun() for fun in funcs] result = {await fun() for fun in funcs} result = {fun: a

[Python-ideas] Shuffled

2016-09-05 Thread Arek Bulski
We should add shuffled() analog to sorted. Also shuffle() should return self so mutating methods could be chained. -- Arkadiusz Bulski -- ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of

Re: [Python-ideas] Shuffled

2016-09-05 Thread Steven D'Aprano
On Tue, Sep 06, 2016 at 02:50:02AM +0200, Arek Bulski wrote: > We should add shuffled() analog to sorted. Also shuffle() should return > self so mutating methods could be chained. from random import shuffle shuffle(mylist) Why is that so important that it needs to be a built-in? In 15+ years of

Re: [Python-ideas] Shuffled

2016-09-05 Thread Bernardo Sulzbach
On 09/05/2016 10:03 PM, Steven D'Aprano wrote: from random import shuffle shuffle(mylist) Why is that so important that it needs to be a built-in? In 15+ years of using Python, I've probably used shuffle() three or four times. Just adding to this. Sorting is a problem that comes up in almost

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread Yury Selivanov
Hi Sven, On 2016-09-05 4:27 PM, Sven R. Kunze wrote: Hi Yury, just for my understanding: On 04.09.2016 01:31, Yury Selivanov wrote: We propose to allow the use of ``await`` expressions in both asynchronous and synchronous comprehensions:: result = [await fun() for fun in funcs] resu

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread Chris Angelico
On Tue, Sep 6, 2016 at 9:27 AM, Sven R. Kunze wrote: > Hi Yury, > > just for my understanding: > > On 04.09.2016 01:31, Yury Selivanov wrote: >> >> We propose to allow the use of ``await`` expressions in both >> asynchronous and synchronous comprehensions:: >> >> result = [await fun() for fun

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread Yury Selivanov
Hi Ivan, On 2016-09-05 3:57 PM, Ivan Levkivskyi wrote: On 4 September 2016 at 01:31, Yury Selivanov > wrote: Below is a proposal to add support for asynchronous comprehensions and asynchronous generator expressions in Python 3.6. Interesting proposal.

Re: [Python-ideas] Shuffled

2016-09-05 Thread Chris Angelico
On Tue, Sep 6, 2016 at 11:03 AM, Steven D'Aprano wrote: > On Tue, Sep 06, 2016 at 02:50:02AM +0200, Arek Bulski wrote: > >> We should add shuffled() analog to sorted. Also shuffle() should return >> self so mutating methods could be chained. > > from random import shuffle > shuffle(mylist) > > Why

Re: [Python-ideas] Shuffled

2016-09-05 Thread Arek Bulski
shuffled() should be in the random module, of course. I dont suggest a builtin. Although now that you mentioned it, I could go for that too. There are usage cases where its heavily used, in randomized testing for example. I am sure that there are also other domains where randomization of lists is

Re: [Python-ideas] Shuffled

2016-09-05 Thread Steven D'Aprano
On Tue, Sep 06, 2016 at 03:59:10AM +0200, Arek Bulski wrote: > Implementing this in pure python wont take a lot of work. Great. Well, here's a tracker issue for it. http://bugs.python.org/issue27964 Can you provide a patch? Don't forget the tests and documentation. Providing a patch doesn't m

Re: [Python-ideas] PEP 530: Asynchronous Comprehensions

2016-09-05 Thread srinivas devaki
On Tue, Sep 6, 2016 at 6:46 AM, Yury Selivanov wrote: > Hi Sven, > > I doubt that anybody ever would write something like that; this is just > examples of what the PEP will enable. using the same object as iterator and async generator, may be not. but isn't it good to write code for sync iteration

Re: [Python-ideas] Shuffled

2016-09-05 Thread Mahmoud Hashemi
I tend to agree with Arek. I've been bitten multiple times, including once yesterday, because shuffle works in place, when I really expect a sorted()-like behavior for a standalone function like that. Mahmoud https://github.com/mahmoud http://sedimental.org On Mon, Sep 5, 2016 at 6:59 PM, Arek Bu

Re: [Python-ideas] Shuffled

2016-09-05 Thread Steven D'Aprano
On Mon, Sep 05, 2016 at 09:34:05PM -0700, Mahmoud Hashemi wrote: > I tend to agree with Arek. I've been bitten multiple times, including once > yesterday, because shuffle works in place, when I really expect a > sorted()-like behavior for a standalone function like that. *shrug* And if random.sh