# For any & every

**URL:** <https://discuss.python.org/t/for-any-every/53302>\
**Category:** Python Help\
**Created:** [May 14, 2024, 2:38pm UTC](https://discuss.python.org/t/for-any-every/53302 "2024-05-14T14:38:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 2:38pm UTC](https://discuss.python.org/t/for-any-every/53302/1 "2024-05-14T14:38:23Z")

</div>

_NOTE: Check [https://github.com/nineteendo/for-any-each](https://github.com/nineteendo/for-any-each) for the latest version._

## The problem

Recently, [#118946](https://github.com/python/cpython/pull/118946) was merged, replacing `any()` with a for loop:

```diff
-return any(key in m for m in self.maps)
+for mapping in self.maps:
+ if key in mapping:
+ return True
+return False

```

Why? Because `any()` is slower in this case:

> **script**
>
> ```python
> # for_all_any.py
> def all_base(stop):
> return all(value >= 0 for value in range(stop))
> 
> def any_base(stop):
> return any(value < 0 for value in range(stop))
> 
> def all_true(stop):
> return all(False for value in range(stop) if value < 0)
> 
> def any_true(stop):
> return any(True for value in range(stop) if value < 0)
> 
> def all_loop(stop):
> for value in range(stop):
> if value < 0:
> return False
> return True
> 
> def any_loop(stop):
> for value in range(stop):
> if value < 0:
> return True
> return False
> 
> ```
> 
> ```sh
> # for_all_any.sh
> echo 1 item
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_base(1)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_base(1)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_true(1)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_true(1)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_loop(1)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_loop(1)"
> echo 10 items
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_base(10)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_base(10)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_true(10)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_true(10)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_loop(10)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_loop(10)"
> echo 100 items
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_base(100)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_base(100)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_true(100)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_true(100)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_loop(100)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_loop(100)"
> echo 1000 items
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_base(1000)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_base(1000)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_true(1000)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_true(1000)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.all_loop(1000)"
> main/python.exe -m timeit -s "import for_all_any" "for_all_any.any_loop(1000)"
> 
> ```

> **2.56x slower for 1 item**
>
> ```none
> 1000000 loops, best of 5: 361 nsec per loop # all_base
> 1000000 loops, best of 5: 358 nsec per loop # any_base
> 1000000 loops, best of 5: 333 nsec per loop # all_true
> 1000000 loops, best of 5: 337 nsec per loop # any_true
> 2000000 loops, best of 5: 142 nsec per loop # all_loop
> 2000000 loops, best of 5: 141 nsec per loop # any_loop
> 
> ```

> **2.30x slower for 10 items**
>
> ```none
> 10 items
> 500000 loops, best of 5: 650 nsec per loop # all_base
> 500000 loops, best of 5: 667 nsec per loop # any_base
> 500000 loops, best of 5: 480 nsec per loop # all_true
> 500000 loops, best of 5: 483 nsec per loop # any_true
> 1000000 loops, best of 5: 283 nsec per loop # all_loop
> 1000000 loops, best of 5: 283 nsec per loop # any_loop
> 
> ```

> **2.12x slower for 100 items**
>
> ```none
> 100 items
> 100000 loops, best of 5: 3.41 usec per loop # all_base
> 100000 loops, best of 5: 3.43 usec per loop # any_base
> 200000 loops, best of 5: 1.77 usec per loop # all_true
> 200000 loops, best of 5: 1.78 usec per loop # any_true
> 200000 loops, best of 5: 1.61 usec per loop # all_loop
> 200000 loops, best of 5: 1.61 usec per loop # any_loop
> 
> ```

> **1.68x slower for 1000 items**
>
> ```none
> 1000 items
> 5000 loops, best of 5: 40.5 usec per loop # all_base
> 5000 loops, best of 5: 40.9 usec per loop # any_base
> 10000 loops, best of 5: 23.8 usec per loop # all_true
> 10000 loops, best of 5: 24 usec per loop # any_true
> 10000 loops, best of 5: 24.3 usec per loop # all_loop
> 10000 loops, best of 5: 24.1 usec per loop # any_loop
> 
> ```

Quoting [the Zen of Python](https://peps.python.org/pep-0020):

> There should be one-- and preferably only one --obvious way to do it.

This is clearly not the case here, the more code you use the faster it gets.  
Therefore, I propose a syntax for `all()` & `any()` with a loop, which the compiler can optimize:

```python
result = value < 0 for any value in range(stop)
result = value >= 0 for every value in range(stop)

```

## Syntax

```none
comprehension ::= assignment_expression comp_for
comp_for ::= comp_unquantified_for | comp_quantified_for
comp_unquantified_for ::= ["async"] "for" target_list "in" or_test
                          [comp_iter]
comp_quantified_for ::= ["async"] "for" quantifier target_list "in"
                          or_test [comp_quantified_for]
quantifier ::= any | every
comp_iter ::= comp_for | comp_if
comp_if ::= "if" or_test [comp_iter]

```

Can always be extended later, but only useful expressions should be allowed.

## Examples

> **expand**
>
> ### Example 1
> 
> ```python
> result = value < 0 for any value in range(stop)
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stop):
> for value in range(stop):
> if value < 0:
> return True
> return False
> 
> result = func(stop)
> 
> ```
> 
> ### Example 2
> 
> ```python
> result = value >= 0 for every value in range(stop)
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stop):
> for value in range(stop):
> if value < 0:
> return False
> return True
> 
> result = func(stop)
> 
> ```
> 
> ### Example 3
> 
> ```python
> result = (
> value < 0
> for any stop in range(stops)
> for any value in range(stop)
> )
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stops):
> for stop in range(stops):
> for value in range(stop):
> if value < 0:
> return True
> return False
> 
> result = func(stops)
> 
> ```
> 
> ### Example 4
> 
> ```python
> result = [
> value < 0
> for stop in range(stops)
> for any value in range(stop)
> ]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stop):
> for value in range(stop):
> if value < 0:
> return True
> return False
> 
> result = []
> for stop in range(stops)
> result.append(func(stop))
> 
> ```

## Other discussions about comprehensions

> **expand**
>
> ### [Itertools.takewhile but in a list comprehension](https://discuss.python.org/t/itertools-takewhile-but-in-a-list-comprehension/21772)
> 
> ```python
> result = [value for value in range(stop) while value < 10]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> result = []
> for value in range(stop):
> if value >= 10:
> break
> result.append(value)
> 
> ```
> 
> Feedback:
> 
> - Cognitive overload
> - Uncommon
> - Intuitive
> - Breaks duality with for loops
> 
> ### [Why no tuple comprehension?](https://discuss.python.org/t/why-no-tuple-comprehension/2820)
> 
> - `(... for ... in ...)` is already used for generator expressions
> - Uncommon
> - Tuples are immutable
> 
> ### [Exception handling syntax in comprehensions](https://discuss.python.org/t/exception-handling-syntax-in-comprehensions/21986)
> 
> ```python
> result = [1 / value for value in range(stop) except ZeroDivisionError]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> result = []
> for value in range(stop):
> try:
> result.append(1 / value)
> except ZeroDivisionError:
> pass
> 
> ```
> 
> Feedback:
> 
> - Less expressive than [PEP 463](https://peps.python.org/pep-0463)
> - Uncommon
> 
> ### [Since comprehension is now inline-ed, shall python allow “yield inside comprehension” again?](https://discuss.python.org/t/since-comprehension-is-now-inline-ed-shall-python-allow-yield-inside-comprehension-again/33640)
> 
> ```python
> def func(stop):
> while True:
> L = [(yield) for _ in range(stop)]
> print(L)
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stop):
> while True:
> L = []
> for _ in range(stop):
> L.append((yield))
> print(L)
> 
> ```
> 
> Feedback:
> 
> - Breaks expectation that comprehensions work in one go
> - If `(yield)` is forbidden in generator expression it should be forbidden in other comprehensions too
> - Uncommon
> 
> ### [Allow comprehension syntax in loop header of for loop](https://discuss.python.org/t/allow-comprehension-syntax-in-loop-header-of-for-loop/25864)
> 
> ```python
> for value in range(stop) if value % 3:
> print(value)
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> for value in range(stop):
> if value % 3:
> print(value)
> 
> ```
> 
> Feedback:
> 
> - Not readable
> - You can use a generator expression
> - There should be one-- and preferably only one --obvious way to do it
> 
> ### [Proposal: `for in match` within list comprehension](https://discuss.python.org/t/proposal-for-in-match-within-list-comprehension/15078)
> 
> ```python
> result = [name for city in cities match City(country='BR', name=name)]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> result = []
> for city in cities:
> match city:
> case City(country='BR', name=name):
> results.append(name)
> 
> ```
> 
> Feedback:
> 
> - Hard to read
> - You can use duck typing
> - Doesn’t offer many optimisation opportunities
> 
> ### [Using unpacking to generalize comprehensions with multiple elements](https://discuss.python.org/t/using-unpacking-to-generalize-comprehensions-with-multiple-elements/35291)
> 
> ```python
> result = [*(value, value + 1) for value in range(1, stop, 3)]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> result = []
> for value in range(1, stop, 3):
> result.extend((value, value + 1))
> 
> ```
> 
> Feedback:
> 
> - You can use nested for loops
> - Not intuitive
> 
> ### [Yield comprehension](https://discuss.python.org/t/yield-comprehension/28819)
> 
> ```python
> def func1(stop):
> yield value ** 2 for value in range(stop)
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func1(stop):
> for value in range(stop):
> value ** 2
> 
> ```
> 
> Feedback:
> 
> - Acts differently with parentheses
> - You can use `yield from`
> - Where does `send(...)` go?
> 
> ### [`where` clauses in List comprehension](https://discuss.python.org/t/where-clauses-in-list-comprehension/20897)
> 
> ```python
> result = [string for string in strings if number % 2 where number = int(string)]
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> result = []
> for string in strings:
> number = int(string)
> if number % 2:
> result.append(string)
> 
> ```
> 
> Feedback:
> 
> - You can use `:=`
> - There should be one-- and preferably only one --obvious way to do it

## GitHub searches

1. [Roughly 2.7M files with `all()` & for](https://github.com/search?q=%2F%5Cball%5C%28%2F+%22for+%22+language%3APython&type=code)
2. [Roughly 1.8M files with `any()` & for](https://github.com/search?q=%2F%5Cbany%5C%28%2F+%22for+%22+language%3APython&type=code)
3. [\>35.8K files with `all()` & `map()`](https://github.com/search?q=%2F%5Cball%5C%28map%5C%28%2F+%22for+%22+language%3APython&type=code)
4. [\>22.1K files with `any()` & `map()`](https://github.com/search?q=%2F%5Cbany%5C%28map%5C%28%2F+%22for+%22+language%3APython&type=code)

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 2:54pm UTC](https://discuss.python.org/t/for-any-every/53302/2 "2024-05-14T14:54:19Z")

</div>

I replaced “every” with “each” as that’s 1 character shorter and still grammatically correct.

---

<div class="post-metadata">

**Author:** ![barneygale](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barneygale/32/1882_2.png) [@barneygale](https://discuss.python.org/u/barneygale)\
**Post date:** [May 14, 2024, 3:19pm UTC](https://discuss.python.org/t/for-any-every/53302/3 "2024-05-14T15:19:41Z")

</div>

Please re-read this post from 2 days ago. You’re still throwing out half-baked ideas and it’s becoming quite annoying.

> [@Alternative call syntax](https://discuss.python.org/t/alternative-call-syntax/53126/16):
>
> That’s not entirely true. Yes, library changes will get pushback of the form “why can’t this be on PyPI”, but that doesn’t mean they never get accepted. It just means the bar for acceptance is high (a lot higher than simply “I just had a good idea, what do you think?”). But the barrier for acceptance of syntax changes is also high - probably even higher than library changes, notwithstanding the previous point. The truth is, getting any sort of change into a widely used, mature language like Py…

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 4:26pm UTC](https://discuss.python.org/t/for-any-every/53302/4 "2024-05-14T16:26:20Z")

</div>

> [@Alternative call syntax](https://discuss.python.org/t/alternative-call-syntax/53126/16):
>
> All you are doing, as has already been mentioned, is using up people’s patience with you to the point where you’re going to start getting ignored and your ideas dismissed.

Sorry, it feels like I already used up your patience with me in my previous posts. So, you just dismissed this one without reading it. That’s fine, focus on improving `pathlib` instead of wasting your time with my ideas.

* * *

> [@Alternative call syntax](https://discuss.python.org/t/alternative-call-syntax/53126/16):
>
> Once you’ve established a reputation like that, then you might find that people are receptive to proposals from you - especially if you take on board all the experience you’ve gained watching how other people’s proposals have fared, and make your own proposal as good as you possibly can.

1. Unlike some other suggestions for improving comprehensions, I’m proposing a faster alternative to constructs which are _widely used_.
2. The notation is natural, corresponding to logical expressions:
  - \forall x \in A: x \>= 0
  - \exists x \in A: x \< 0.

3. There isn’t an obvious way to write these checks that’s both fast and concise, this proposal tries to address that.

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [May 14, 2024, 4:42pm UTC](https://discuss.python.org/t/for-any-every/53302/5 "2024-05-14T16:42:23Z")

</div>

> [@Nineteendo](#):
>
> > [@barneygale](#):
> >
> > You’re still throwing out half-baked ideas and it’s becoming quite annoying.
> 
> Do you think that because I replaced “every” with “each”, indicating that the details might not be finalised yet? Or because I don’t have an implementation for this idea?

I am not Barney, but I would also say it’s half baked. You haven’t actually thought this through. Modifying the comprehension syntax is fundamentally the wrong idea. You want to add a new syntax that looks like Comprehensions. The existing comprehensions result in multiple values and can be used to construct generators, sets, lists or dictionaries. This is fundamentally not what your proposal does. I don’t see you address this anywhere. This for example means that your “syntax” section is just incomplete: It doesn’t actually allow the examples you want to write down.

I am going to make a slightly stronger suggestion than has been made up until now by others: Please don’t make further suggestion unless you have a working prototype. Doesn’t have to pretty code, it just needs to show that you considered this enough to get something that actually can work.

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 5:01pm UTC](https://discuss.python.org/t/for-any-every/53302/6 "2024-05-14T17:01:14Z")

</div>

> [@MegaIng](#):
>
> Modifying the comprehension syntax is fundamentally the wrong idea. You want to add a new syntax that looks like Comprehensions.

Do you have a better idea? Implementing this without using any new keywords is hard.  
I’m happy to drop this in case we can do this without using the comprehension syntax though.

* * *

> [@MegaIng](#):
>
> This for example means that your “syntax” section is just incomplete: It doesn’t actually allow the examples you want to write down.

You mean that `comprehension` should always result in multiple values and `quantified_comprehension` in a single value? That’s should be an easy fix.

* * *

> [@MegaIng](#):
>
> Please don’t make further suggestion unless you have a working prototype.

I think it would be a huge waste of my time if I spent weeks implementing something that’s rejected with one word: “ **NO!** ”. Writing this up already took long enough, because I did some research for once. Also, I’m far more experienced with Python than C as C isn’t as user friendly.

---

<div class="post-metadata">

**Author:** ![MegaIng](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/megaing/32/16162_2.png) [@MegaIng](https://discuss.python.org/u/MegaIng)\
**Post date:** [May 14, 2024, 5:08pm UTC](https://discuss.python.org/t/for-any-every/53302/7 "2024-05-14T17:08:48Z")

</div>

> [@Nineteendo](#):
>
> Do you have a better idea? Implementing this without using any new keywords is hard.  
> I’m happy to drop this in case we can do this without using the comprehension syntax though.

That’s not my point. I do somewhat like the syntax, although I don’t think it’s all that clear. The point is that you don’t seem to understand what comprehensions currently are and what exactly the implications of your suggested change are.

> [@Nineteendo](#):
>
> You mean that `comprehension` should always result in multiple values and `quantified_comprehension` in a single value? That’s should be an easy fix.

Surely `quantified_comprehensions` can only ever result in one value? Otherwise you need to describe the semantics better, since I don’t know how you expected that to potentially result in multiple values.

But what I mean is that currently, `a = x for x in range(5)` is not valid syntax. Nothing in your proposed syntax changes enables `a = x for any x in range(5)` to be valid. And you have not discussed the implications of allowing unbracketed comprehension-like syntax, which would be completely new syntax.

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 5:17pm UTC](https://discuss.python.org/t/for-any-every/53302/8 "2024-05-14T17:17:44Z")

</div>

> [@MegaIng](#):
>
> Surely `quantified_comprehensions` can only ever result in one value? Otherwise you need to describe the semantics better, since I don’t know how you expected that to potentially result in multiple values.

Yes, that’s why they need to be split up from `unquantified_comprehensions`. I updated the syntax above.

* * *

> [@MegaIng](#):
>
> But what I mean is that currently, `a = x for x in range(5)` is not valid syntax.

Oh, I thought that worked for generators. I haven’t used them very often. I added parentheses.

---

<div class="post-metadata">

**Author:** ![JamesParrott](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamesparrott/32/10534_2.png) [@JamesParrott](https://discuss.python.org/u/JamesParrott)\
**Post date:** [May 14, 2024, 5:51pm UTC](https://discuss.python.org/t/for-any-every/53302/9 "2024-05-14T17:51:52Z")

</div>

I got similar timing benchmarks from 1000 items. There’s absolutely no need for new syntax, but perhaps it’s food for thought about the implementation of `any` and `all`. But if 1000 iterations in 90 microseconds isn’t fast enough for some application, perhaps Python is not the best tool for it in the first place.

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 5:58pm UTC](https://discuss.python.org/t/for-any-every/53302/10 "2024-05-14T17:58:17Z")

</div>

> [@JamesParrott](#):
>
> perhaps it’s food for thought about the implementation of `any` and `all`

That’s sadly not possible, they are regular builtin functions (no keyword), all they see is a generator.

* * *

> [@JamesParrott](#):
>
> if 1000 iterations in 90 microseconds isn’t fast enough for some application

I think it’s still bad that you need to write out the for loop if you want the best performance.  
I don’t think it’s productive to replace all occurences in the stdlib with for loops, which is why I think we need this.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [May 14, 2024, 6:04pm UTC](https://discuss.python.org/t/for-any-every/53302/11 "2024-05-14T18:04:39Z")

</div>

> [@Nineteendo](#):
>
> Sorry, it feels like I already used up your patience with me in my previous posts.

You have used up a LOT of people’s patience. Probably more people than you realise - you won’t know how many people just see your name and move on. Or maybe have even blocked you, so they don’t even see your posts.

> [@Nineteendo](#):
>
> Do you think that because I replaced “every” with “each”, indicating that the details might not be finalised yet? Or because I don’t have an implementation for this idea?

Neither. It’s because the idea gives the impression that it hasn’t had a lot of effort put into figuring out how well it fits into Python.

I’m not going to explain that further, because you have already been told to **go and read more of the archives** instead of continuing to burn what patience people have left.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [May 14, 2024, 6:08pm UTC](https://discuss.python.org/t/for-any-every/53302/12 "2024-05-14T18:08:21Z")

</div>

> [@Nineteendo](#):
>
> I think it would be a huge waste of my time if I spent weeks implementing something that’s rejected with one word: “ **NO!** ”. Writing this up already took long enough, because I did some research for once.

How many hours did you spend on it?

How many people have read this thread? How much of their time have you consumed?

How much additional time of everyone’s have you wasted by, once again, making substantive edits to your posts, despite repeated requests to not do this?

Try to get a very very rough idea of how much of other people’s time you’re wasting with half-baked ideas, and then maybe the “huge waste of time” will be put into better perspective.

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 6:17pm UTC](https://discuss.python.org/t/for-any-every/53302/13 "2024-05-14T18:17:13Z")

</div>

> [@Rosuav](#):
>
> I’m not going to explain that further, because you have already been told to **go and read more of the archives** instead of continuing to burn what patience people have left.

I think I went through enough discussions about comprehensions. Expand this: [For any & every](https://discuss.python.org/t/for-any-every/53302#other-discussions-about-comprehensions-8)

* * *

> [@Rosuav](#):
>
> How many hours did you spend on it?

Frankly, I don’t know. I started writing this 2 days ago: [GitHub - nineteendo/for-any-each](https://github.com/nineteendo/for-any-each)

* * *

> [@Rosuav](#):
>
> How many people have read this thread? How much of their time have you consumed?

128 people have viewed (not necessary read) this thread. I don’t know how much time they spent on it.

* * *

> [@Rosuav](#):
>
> How much additional time of everyone’s have you wasted by, once again, making substantive edits to your posts, despite repeated requests to not do this?

I’m not the only person that does this, but you only complain about me. And I have mentioned every change I made, do I need to provide a diff as well? What’s the downside of cleaning them up?

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 6:19pm UTC](https://discuss.python.org/t/for-any-every/53302/14 "2024-05-14T18:19:48Z")

</div>

I updated the examples and the syntax:

> [@Nineteendo](#):
>
> ```python
> result = (value < 0 for any value in range(stop))
> result = (value >= 0 for each value in range(stop))
> 
> ```

> [@Nineteendo](#):
>
> ```python
> unquantified_comprehension ::= assignment_expression comp_unquantified_for
> quantified_comprehension ::= assignment_expression comp_quantified_for
> comp_for ::= comp_unquantified_for | comp_quantified_for
> comp_unquantified_for ::= ["async"] "for" target_list "in" or_test
> [comp_iter]
> comp_quantified_for ::= ["async"] "for" quantifier target_list "in"
> or_test [comp_quantified_for]
> quantifier ::= any | each
> comp_iter ::= comp_for | comp_if
> comp_if ::= "if" or_test [comp_iter]
> 
> ```

---

<div class="post-metadata">

**Author:** ![elis.byberi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/elis.byberi/32/35937_2.png) [@elis.byberi](https://discuss.python.org/u/elis.byberi)\
**Post date:** [May 14, 2024, 6:23pm UTC](https://discuss.python.org/t/for-any-every/53302/15 "2024-05-14T18:23:36Z")

</div>

(This is off-topic.)

For reference, I have over 20 years of experience in programming in general, and over 10 years in Python. However, I still wouldn’t call myself proficient in Python; I tend to forget things I don’t use frequently and often learn new things the hard way. I haven’t read the full Python reference from top to bottom because many concepts are outside my interest and understanding, making little sense to me.

In **recent years** , I’ve been implementing a Domain Specific Language (DSL), which has sparked my keen interest in Python ideas. When you see me leaving a comment, you should know that I’ve been studying the topic for weeks or months across multiple programming languages.

Also, you might have noticed that I don’t have a single comment in typing-related threads. It’s beyond my expertise!

---

<div class="post-metadata">

**Author:** ![Nineteendo](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nineteendo/32/19122_2.png) [@Nineteendo](https://discuss.python.org/u/Nineteendo)\
**Post date:** [May 14, 2024, 6:25pm UTC](https://discuss.python.org/t/for-any-every/53302/16 "2024-05-14T18:25:25Z")

</div>

In case you missed this edit:

> [@Nineteendo](#):
>
> > [@barneygale](#):
> >
> > You’re still throwing out half-baked ideas and it’s becoming quite annoying.
> 
> Do you think that because I replaced “every” with “each”, indicating that the details might not be finalised yet? Or because I don’t have an implementation for this idea?
> 
> I only recently realised `for all ... in ...` wasn’t gramatically correct, so I replaced this with `for every ... in ...`. Because this was a bit too long for my liking I looked for a synonym replacing it with `for each ... in ...`.
> 
> I think the rest is well thought out. Although there might be a better syntax for this. Not sure.

---

<div class="post-metadata">

**Author:** ![Kxnr](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/kxnr/32/18937_2.png) [@Kxnr](https://discuss.python.org/u/Kxnr)\
**Post date:** [May 14, 2024, 6:38pm UTC](https://discuss.python.org/t/for-any-every/53302/17 "2024-05-14T18:38:39Z")

</div>

Another, hopefully gentle, perspective from someone new to this community \[1\] is to consider the audience here. On the whole, folks are here because they like Python. It may not be perfect, but that’s true of every language \[2\]. Making a change to Python means understanding what challenges other folks here face and getting the community \[3\] to agree that there’s a problem worth solving. Building that kind of consensus is hard, especially in a community as broad as Python’s, and that’s before trying to get the community to agree on a solution.

As Paul mentioned in the linked thread \[4\], this means listening to other people here and understanding what they want solved. Perhaps more importantly, understanding why whatever that is isn’t solved yet. An idea being under baked doesn’t only mean that the syntax is underspecified or some similar technicality. It also means understanding who needs this problem solved and what they need out of the solution.

edit: whitespace

* * *

1. longtime lurker, recently first time caller 

2. English included 

3. TM 

4. on the off chance you’re reading this, thanks. I appreciate the advice, even if I’m not directly part of the conversation

---

<div class="post-metadata">

**Author:** ![fungi](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/fungi/32/5963_2.png) [@fungi](https://discuss.python.org/u/fungi)\
**Post date:** [May 14, 2024, 6:40pm UTC](https://discuss.python.org/t/for-any-every/53302/18 "2024-05-14T18:40:18Z")

</div>

> 128 people have viewed (not necessary read) this thread. I don’t  
> know how much time they spent on it.

Those of us participating in “mailing list mode” don’t show up in  
that count.

> I’m not the only person that does this, but you only complain  
> about me. And I have mentioned every change I made, do I need to  
> provide a diff as well? What’s the downside of cleaning them up?

Those of us participating in “mailing list mode” will never see your  
edits, because they’re only to the historical copy kept on the web  
forum and aren’t sent as updates to subscribers.

---

<div class="post-metadata">

**Author:** ![pf\_moore](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pf_moore/32/35_2.png) [@pf\_moore](https://discuss.python.org/u/pf_moore)\
**Post date:** [May 14, 2024, 7:02pm UTC](https://discuss.python.org/t/for-any-every/53302/19 "2024-05-14T19:02:02Z")

</div>

> [@Nineteendo](#):
>
> In case you missed this edit:

Please stop editing posts. Instead of thinking of your posts as documents that can be revised, think of them as part of a conversation. When you talk to someone, what you say can’t be changed or unsaid. Instead you have to make a new statement correcting yourself and incorporating whay others have said into your _subsequent_ statements. That’s how people read forum posts, and interact with others on forums. Edits disrupt that flow, and are frankly considered impolite.

If you want to be part of this community, you need to work _with_ the establish models of communication, not continually fight against them.

> [@Nineteendo](#):
>
> I’m not the only person that does this, but you only complain about me.

Not particularly true. Generally, _everyone_ who doesn’t follow community norms gets corrected. Some accept the correction and get better. Others refuse to listen and get ignored, ultimately leaving the community. From my point of view, you’re somewhere in the middle (and that might be why you’re seeing so much pushback). You appear willing to learn and try to fit in with the community, so we are happy to help you do that\[1\]. But as time goes on, your actions don’t seem to match your words - you engage with the advice you’ve been given and discuss it, but your _behaviour_ isn’t changing. The willingness to help at that point turns into frustration, and finally people simply start giving up as the effort we’re putting into trying to help you work with the community is starting to feel wasted.

At this point, I honestly don’t know if the comment above will help you. I’m not quite willing to give up trying yet, but I’m no longer optimistic.

> [@Nineteendo](#):
>
> Sorry, it feels like I already used up your patience with me in my previous posts. So, you just dismissed this one without reading it.

… and it’s comments like this that make me think I’m getting nowhere with you.

Why do you think I didn’t read your suggestion? I’m borderline insulted that you think I’d comment without trying to understand what I’m responding to. The truth is, I _do_ read your suggestions (this and the others you have made) but they are so vague and unclear that I barely understand them most of the time.

In this post, you proposed a syntax. You even wrote out the BNF. Great. But the syntax you were proposing was straightforward - allow “for any” or “for each” in place of “for”. But you haven’t provided any explanation of the _semantics_. You’ve not said what the new constructs would _do_. Without that, your proposal has no value. And there’s nothing substantive to respond to.

And even if you do provide semantics, you’ve still only barely scratched the surface. Just having syntax and semantics doesn’t mean a proposal is viable. For example, I could propose that we allow a new statement `variable++` which is semantically equivalent to `variable += 1`. That’s far more clearly defined than any of your proposals have been so far, and yet it’s not going to happen (read the archives for why, it’s not relevant here and now).

I’m sorry, but I genuinely don’t know how to make it any clearer than this. If you still don’t understand what’s wrong with the way you’re engaging with this forum, I don’t think I can help you. I’ll still read your proposals, and maybe even respond to them (although I suspect I’ll just be saying “you haven’t explained your proposal well enough” again 🙁), but I’ve got nothing more I can offer on how to improve the feedback you get…

* * *

1. certainly I am

---

<div class="post-metadata">

**Author:** ![FelixFourcolor](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/felixfourcolor/32/13104_2.png) [@FelixFourcolor](https://discuss.python.org/u/FelixFourcolor)\
**Post date:** [May 14, 2024, 7:13pm UTC](https://discuss.python.org/t/for-any-every/53302/20 "2024-05-14T19:13:04Z")

</div>

> [@pf\_moore](#):
>
> But you haven’t provided any explanation of the _semantics_. You’ve not said what the new constructs would _do_.

To be fair, they did

> [@Nineteendo](#):
>
> ```python
> result = (value < 0 for any value in range(stop))
> 
> ```
> 
> Would be roughly equivalent to:
> 
> ```python
> def func(stop):
> for value in range(stop):
> if value < 0:
> return True
> return False
> 
> result = func(stop)
> 
> ```

[Next page](https://discuss.python.org/t/for-any-every/53302.md?page=2)
