On Fri, Apr 10, 2020 at 5:26 PM Elliott Dehnbostel <[email protected]>
wrote:
> Hello Everyone,
>
> If I've done this incorrectly, please let me know so that I can
> improve/revise. I'm new to the Python community and quite enjoy the more
> functional features of Python 3, but have I have a peeve about it. I'd like
> to propose and discuss the following enhancement to Python 3:
>
> *Consider the following trivial for-loop:*
>
> chars = "abcaaabkjzhbjacvb"
> seek = {'a','b','c'}
> count = 0for a in chars:
> if a in seek:
> count += 1
>
> Gross. Twice nested for a simple count.
>
>
count = 0
for a in chars:
count = count + 1 if a in seek else count
Once nested -- if nested == gross, then this is not gross. (However, I
prefer the twice nested which I find clear and simple -- not gross.)
André Roberge
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/A2PTKIJX5XY6Y2ZH7RAZJPGLFJDHTF5S/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/POSK2NKQB4B2Z3GHBJLDPDCH5TYC3AVC/
Code of Conduct: http://python.org/psf/codeofconduct/