[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Rob Cliffe via Python-ideas
On 19/06/2021 05:33, Guido van Rossum wrote: On Fri, Jun 18, 2021 at 8:40 PM Steven D'Aprano > wrote: On Fri, Jun 18, 2021 at 07:38:49AM -0700, Guido van Rossum wrote: > Note the ambiguity around whether the user might have meant > >     [x,(y for y

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Chris Angelico
On Sat, Jun 19, 2021 at 5:13 PM Rob Cliffe via Python-ideas wrote: > > > > On 19/06/2021 05:33, Guido van Rossum wrote: > > On Fri, Jun 18, 2021 at 8:40 PM Steven D'Aprano wrote: >> >> On Fri, Jun 18, 2021 at 07:38:49AM -0700, Guido van Rossum wrote: >> >> > Note the ambiguity around whether the

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Serhiy Storchaka
18.06.21 17:38, Guido van Rossum пише: > Note the ambiguity around whether the user might have meant > >     [x,(y for y in a)] > > or > >     [(x, y) for y in a] Yes, I think that it could be interpreted in one of the following ways: [x, (y for y in a)] [x, *(y for y in a)] [(x

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Steven D'Aprano
Why are we arguing about `[x,y for y in a]` when nobody has requested that syntax? -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/p

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Serhiy Storchaka
18.06.21 18:42, Mathew Elman пише: > I don't see how allowing > > [x, y for x in a] > > follows from allowing > > [*chunk for chunk in list_of_lists]. Because in all other contexts you can replace `*(x, y)` with `x, y`. f(*(x, y)) => f(x, y) [*(x, y)] => [x, y] {*(x, y)} => {x,

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Serhiy Storchaka
19.06.21 07:33, Guido van Rossum пише: > [1] Does the unary star operator have a name when used like this in > Python? In JavaScript the equivalent syntax ("...chunk", where the "..." > are a literal ellipsis) is called "spread". We could borrow this term. I would not call is an operator. Operator

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Ricky Teachey
On Sat, Jun 19, 2021, 5:00 AM Steven D'Aprano wrote: Why are we arguing about `[x,y for y in a]` when nobody has requested that syntax? -- Steve I've wanted many times to be able to write the star unpack there, even as a relatively modestly experienced python user. But it has never occurred t

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Guido van Rossum
On Fri, Jun 18, 2021 at 10:15 PM Steven D'Aprano wrote: > On Fri, Jun 18, 2021 at 09:33:49PM -0700, Guido van Rossum wrote: > > > Now, this shouldn't be considered an airtight argument against [*chunk > for > > ...], but it does show that there's no straightforward explanation of its > > meaning

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Marc-Andre Lemburg
On 19.06.2021 17:03, Guido van Rossum wrote: > I think I would find flatten(a) more readable than [*chunk for chunk in a], > and > more discoverable: this operation is called "flatten" in other languages, so > users are going to search the docs or help for that. +1 > But there could be endless d

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Serhiy Storchaka
19.06.21 18:12, Marc-Andre Lemburg пише: >> But there could be endless debate about whether flatten( ("x", "y") ) should >> return a list or a tuple... > > Have it return an iterator :-) flatten = itertools.chain.from_iterable ___ Python-ideas mailing

[Python-ideas] Re: Deprecate sum of lists

2021-06-19 Thread Marc-Andre Lemburg
On 19.06.2021 17:17, Serhiy Storchaka wrote: > 19.06.21 18:12, Marc-Andre Lemburg пише: >>> But there could be endless debate about whether flatten( ("x", "y") ) should >>> return a list or a tuple... >> >> Have it return an iterator :-) > > flatten = itertools.chain.from_iterable Well, like I sa

[Python-ideas] Re: Allow modifying message of TypeError from NotImplemented

2021-06-19 Thread Jeff Allen
On 19/06/2021 05:38, Steven D'Aprano wrote: On Sat, Jun 19, 2021 at 03:30:05AM -, wyz2...@163.com wrote: Python raises TypeError when NotImplemented is returned from __add__, __invert__ etc. and __radd__ etc. aren't available. Roughly correct. It's more complex than that. I just wanted to

[Python-ideas] Re: channel or message queue in asyncio

2021-06-19 Thread Rene Nejsum
Sound like a good idea. Would be supernice if the channel could receive (ch.get()) multiple types of events like: network messages (socket), UI input (mouse and keyboard events), file events (select?), timeouts, kernel events (shutdown) and signals besides internal messages (ch.put) br /Rene

[Python-ideas] Re: Allow modifying message of TypeError from NotImplemented

2021-06-19 Thread Serhiy Storchaka
19.06.21 06:30, wyz2...@163.com пише: > Python raises TypeError when NotImplemented is returned from __add__, > __invert__ etc. and __radd__ etc. aren't available. > However, this disallows the customization of error messages. For example, in > Python 3.8, __float__ etc. were removed from complex