On Sat, May 1, 2021 at 1:43 PM Valentin Berlier <berlie...@gmail.com> wrote: > > > the ONLY predicate that can be expressed about a single character is it > > being a member of a subset of all Unicode characters > > You seem to be assuming that the comprehension would be purposefully > restricted to iterating over strings. The original author already provided > examples with predicates that don't involve checking for a subset of > characters. > > old = [0, 1, None, 2] > new = c"str(x + 1) for x in old if isinstance(x, int)" > > The existing "".join() idiom isn't restricted to iterating over an existing > string. You also have to account for nested comprehensions. There's nothing > that would prevent you from having arbitrary complexity in string > comprehension predicates, just like nothing prevents you from having > arbitrary predicates when you join a generator expression. >
Rather than toy examples, how about scouring the Python standard library for some real examples? Find some actual existing code and show how it would be improved by this new construct. Consistency on its own is not a sufficient goal; you have to demonstrate that the change would be of material value. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5ENHH4PPFNSIIXRWQ76XLJL7R3L6GMAN/ Code of Conduct: http://python.org/psf/codeofconduct/