10.04.20 23:21, Elliott Dehnbostel пише:
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=  0
for  ain  chars:
      if  ain  seek:
           count+=  1
Gross. Twice nested for a simple count.

/We could refactor the block like so:/

Don't listen to anyone. There is only one obvious way to write this in one line:

count = +(lambda *a: a[0](*a))((lambda q, r, s, i: r(r, q, s, i, next(i, s))), (lambda r, q, s, i, x: x is not s and (x in seek) + q(q, r, s, i)), [], iter(chars))

It is not even use such non-functional paradigm as a for loop.
_______________________________________________
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/UGRLITPML573HQSAARU35M53QIVFLJSR/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to