> 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.
_______________________________________________
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/6T7NQT5HFVYSI3RHUCBDDCEWKJ7HDPZG/
Code of Conduct: http://python.org/psf/codeofconduct/