[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Jonathan Fine
Guido wrote: I honestly and strongly believe that we should do nothing here. Python > thrives because it is relatively simple. Adding new syntax to deal with > looping special cases makes it less simple, and encourages a bad coding > style (nested loops, multiple breaks...). > I agree with about

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread 2QdxY4RzWzUUiLuE
On 2020-07-29 at 07:09:05 -0700, Guido van Rossum wrote: > I honestly and strongly believe that we should do nothing here. Python > thrives because it is relatively simple. Adding new syntax to deal > with looping special cases makes it less simple, and encourages a bad > coding style (nested loo

[Python-ideas] Re: Access (ordered) dict by index; insert slice

2020-07-29 Thread Wes Turner
.iloc[] is the Pandas function for accessing by integer-location: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.iloc.html """ Purely integer-location based indexing for selection by position. .iloc[] is primarily integer position based (from 0 to length-1 of the axi

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Stephen J. Turnbull
Jonathan Fine writes: > Here's a baby example - searching in a nested loop. Suppose we're > looking for the word 'apple' in a collection of books. Once we've > found it, we stop. While I was writing a reply, several people replied with very similar comments, so I won't repeat them. But these

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Guido van Rossum
On Wed, Jul 29, 2020 at 07:01 Mathew Elman wrote: > > > On Wed, 29 Jul 2020 at 14:42, Guido van Rossum wrote: > >> On Wed, Jul 29, 2020 at 02:51 Mathew Elman >> wrote: >> >>> >>> . >>> If it *is* useful, it occurs to me that (1) this looks a lot like the try ... except ... pattern, an

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Mathew Elman
On Wed, 29 Jul 2020 at 14:42, Guido van Rossum wrote: > On Wed, Jul 29, 2020 at 02:51 Mathew Elman wrote: > >> >> . >> >>> If it *is* useful, it occurs to me that (1) this looks a lot like the >>> try ... except ... pattern, and (2) breaks are generally perceived as >>> exceptional exits from a

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Ethan Furman
On 7/28/20 10:30 PM, Rob Cliffe via Python-ideas wrote: A possible, unrelated, future language extension is to allow breaking out of more than one loop at a time. I would think that break would handle that situation. -- ~Ethan~ ___ Python-ide

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Dominik Vilsmeier
On 29.07.20 13:33, Jonathan Fine wrote: Thank you all, particularly Guido, for your contributions. Having some examples will help support the exploration of this idea. Here's a baby example - searching in a nested loop. Suppose we're looking for the word 'apple' in a collection of books. Once w

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Guido van Rossum
On Wed, Jul 29, 2020 at 02:51 Mathew Elman wrote: > > . > >> If it *is* useful, it occurs to me that (1) this looks a lot like the >> try ... except ... pattern, and (2) breaks are generally perceived as >> exceptional exits from a loop. Instead of "if break [LABEL]", "except >> [LABEL]" might w

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Jonathan Fine
Thank you all, particularly Guido, for your contributions. Having some examples will help support the exploration of this idea. Here's a baby example - searching in a nested loop. Suppose we're looking for the word 'apple' in a collection of books. Once we've found it, we stop. for book in bo

[Python-ideas] Re: Thoughts about implementing object-compare in unittest package?

2020-07-29 Thread 2QdxY4RzWzUUiLuE
On 2020-07-29 at 14:26:25 +0900, "Stephen J. Turnbull" wrote: > 2qdxy4rzwzuui...@potatochowder.com writes: > > > in order to foil suck attacks. > > Typo of the Year candidate! (It was a typo, right?) Call it a Freudian slip of the fingers. ___ Pyth

[Python-ideas] Re: Idea: Extend "for ... else ..." to allow "for ... if break ..." else

2020-07-29 Thread Mathew Elman
. > If it *is* useful, it occurs to me that (1) this looks a lot like the > try ... except ... pattern, and (2) breaks are generally perceived as > exceptional exits from a loop. Instead of "if break [LABEL]", "except > [LABEL]" might work, although the semantic difference between labels > and ex

[Python-ideas] Re: Fwd: Re: Experimenting with dict performance, and an immutable dict

2020-07-29 Thread Marco Sulla
On Wed, 29 Jul 2020 at 06:41, Inada Naoki wrote: > FWIW, I optimized dict(d) in https://bugs.python.org/issue41431 > (https://github.com/python/cpython/pull/21674 ) > [...] 4.76x faster (-79%) > Great! On Wed, 29 Jul 2020 at 06:41, Inada Naoki wrote: > On Sun, Jul 26, 2020 at 4:44 AM Marco Su