Timeline for Get the first item from an iterable that matches a condition
Current License: CC BY-SA 4.0
21 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 23, 2022 at 5:40 | comment | added | Robert Siemer |
@cowlinator No. It is not for next() to decide if it will be “idempotent”. It is the_iterable which does: if it is a generator, neither next() nor any other solution can reset it. If the_iterable is a e.g. a list or tuple, then next() will be “idempotent”.
|
|
Feb 16, 2022 at 8:55 | history | edited | Neuron | CC BY-SA 4.0 |
Make it easier to see which section covers which python versions at a glance
|
Nov 9, 2021 at 2:57 | comment | added | cowlinator |
Note that this is not idempotent. (Meaning that next() will only return the first element the first time it is called).
|
|
S Sep 6, 2021 at 20:57 | history | edited | Neuron | CC BY-SA 4.0 |
Make clear that answer is usable for python 3
|
S Sep 6, 2021 at 20:57 | history | suggested | Joep | CC BY-SA 4.0 |
Make clear that answer is usable for python 3
|
Sep 6, 2021 at 14:11 | review | Suggested edits | |||
S Sep 6, 2021 at 20:57 | |||||
Apr 11, 2021 at 17:12 | comment | added | CrazyChucky | @OlivierPons It stops as soon as it finds a match, if there is one. | |
Jul 13, 2020 at 16:28 | comment | added | Olivier Pons | Does it parse the whole array, or does it stop at the first matching element (very important for efficiency)? | |
Jun 10, 2020 at 13:30 | history | edited | Nico Schlömer | CC BY-SA 4.0 |
added 21 characters in body
|
S Mar 15, 2020 at 19:38 | history | suggested | kokociel | CC BY-SA 4.0 |
Whether or not newer versions are "better" is just an opinion
|
Mar 15, 2020 at 18:12 | review | Suggested edits | |||
S Mar 15, 2020 at 19:38 | |||||
Jan 26, 2018 at 3:25 | comment | added | Guy |
My view is a little different than the time I wrote the comment. I see your point. That's being said, having to handle StopIteration is really not pretty. Better use a method.
|
|
Jan 24, 2018 at 23:34 | comment | added | Abraham Toledo | @guyarad how is the solution proposed in that answer less "cryptic" than just using next ? The only argument against next (in that answer) is that you must handle an exception; really ? | |
S Jan 18, 2017 at 10:54 | history | suggested | Arye Shemesh | CC BY-SA 3.0 |
Move the options explanation before the code for better understanding of them.
|
Jan 18, 2017 at 9:38 | review | Suggested edits | |||
S Jan 18, 2017 at 10:54 | |||||
Jul 7, 2016 at 10:56 | comment | added | Guy | Since this is the selected answer, I feel compelled to share an answer to selecting the first element correctly here. In short: usage of next shouldn't be encouraged. | |
Jan 6, 2016 at 19:06 | history | edited | Cristian Ciupitu | CC BY-SA 3.0 |
added links to documentation
|
Jan 18, 2013 at 17:51 | history | edited | Kos | CC BY-SA 3.0 |
reworded the first paragraph to avoid confusion
|
Mar 3, 2010 at 17:23 | vote | accept | Chris Phillips | ||
Mar 3, 2010 at 17:23 | vote | accept | Chris Phillips | ||
Mar 3, 2010 at 17:23 | |||||
Mar 2, 2010 at 15:29 | history | answered | Alex Martelli | CC BY-SA 2.5 |