Any thoughts on logging a warning, perhaps behind an opt-in flag? I could not
find a single false positive scenario, so I expect the signal-to-noise ratio to
be high and prevent lots of bugs.
BoppreH
On Tue, Jun 13, 2023, at 1:05 AM, Greg Ewing wrote:
> On 13/06/23 9:59 am, Rob Cliffe via Pytho
The original example is:
numbers = (i for i in range(5))
assert 5 not in numbers
sorted(numbers)
I like this example. It provides an opportunity to improve the
documentation.
The problems goes away if we write any of the following
numbers = [i for i in range(5)]
numbers = tup
On Tue, 13 Jun 2023 at 21:03, BoppreH via Python-ideas
wrote:
>
> Any thoughts on logging a warning, perhaps behind an opt-in flag? I could not
> find a single false positive scenario, so I expect the signal-to-noise ratio
> to be high and prevent lots of bugs.
>
Shadow the iter() function and
@ChrisA: Shadowing "iter()" would only help with Barry's example.
@Jonathan: Updating documentation is helpful, but I find an automated check
better. Too often the most obvious way to accomplish something silently
triggers this behavior:
strings = ['aa', '', 'bbb', 'c']
strings = filter(bool, s
On Wed, 14 Jun 2023 at 01:07, BoppreH via Python-ideas
wrote:
> And I have to say I'm surprised by the responses. Does nobody else hit bugs
> like this and wish they were automatically detected?
>
Nope, I've never had that happen to me, and I *have* made use of
calling iter() on potentially-exha
On 2023-06-13 16:42, Chris Angelico wrote:
On Wed, 14 Jun 2023 at 01:07, BoppreH via Python-ideas
wrote:
And I have to say I'm surprised by the responses. Does nobody else hit bugs
like this and wish they were automatically detected?
Nope, I've never had that happen to me, and I *have* made
In close to 10 years of experience with python I have never encountered
anything like this.
If I need to use a list later I never do ANY assignments to it. Why would I?
In the last example I would:
```
strings = ['aa', '', 'bbb', 'c’]
longest = max(filter(bool, strings), key=len)
n_unique = len(
> In close to 10 years of experience with python I have never encountered
> anything like this.
Here's a small selection of the StackOverflow questions from people who
encountered this exact issue:
https://stackoverflow.com/questions/25336726/why-cant-i-iterate-twice-over-the-same-iterator-how-
On Wed, 14 Jun 2023 at 07:02, BoppreH via Python-ideas
wrote:
>
> > In close to 10 years of experience with python I have never encountered
> > anything like this.
>
> Here's a small selection of the StackOverflow questions from people who
> encountered this exact issue:
But now try to find peo
Sorry, I'm new to the list and was not aware the burden of proof was so high.
Can you point me to one or two successful posts in Python-ideas where I can
learn how to show there's a real need for a feature?
On Tue, Jun 13, 2023, at 11:25 PM, Chris Angelico wrote:
> On Wed, 14 Jun 2023 at 07:02,
On Wed, 14 Jun 2023 at 07:52, BoppreH via Python-ideas
wrote:
>
> Sorry, I'm new to the list and was not aware the burden of proof was so high.
> Can you point me to one or two successful posts in Python-ideas where I can
> learn how to show there's a real need for a feature?
>
It's more a matt
I've also been a Python user for 24 years now. Since long before iterators
were a feature of Python. I wrote quite a few widely read articles about
iterators when they were introduced, including the first about leverageing
iterators for coroutines.
I can't say I've NEVER encountered a glitch wit
> > If I wanted sorted numbers, then ValueError wouldn’t help, because I do not
> > get sorted numbers.
>
> I do want sorted numbers, but what can Python do in the face of broken code?
> There's a reason it raises errors for 1/0, str.invalid, and len(None). It's
> not "helpful" to the program
I think the discussion is sort of missing a very common use case, when a
user calls func(iterator) and the function is expecting an iterable but not
an iterator. The author of the called code might be thinking that the input
is a list but that doen't mean the caller thinks that. Even worse is a cas
@ChrisA: There are already flags for enabling warnings on dangerous bytearray
comparisons[1] or relying on locale-dependent encodings[2], not to mention a
whole Development Mode flag[3] that adds extra checks. Some of those checks
affect fewer people than my proposal. A "warn on reused generator
On Wed, 14 Jun 2023 at 09:05, BoppreH via Python-ideas
wrote:
>
> @ChrisA: There are already flags for enabling warnings on dangerous bytearray
> comparisons[1] or relying on locale-dependent encodings[2], not to mention a
> whole Development Mode flag[3] that adds extra checks. Some of those ch
I know this is not the point of this thread, but when i saw:
```
numbers = (i for i in range(10))
assert 3 in numbers
next(numbers)# 4!
```
I was totally surprised that generator expressions support `in` -- WTF?
they very much are NOT containers!
And, in fact, all iterators support `in` -- wo
17 matches
Mail list logo