I'm new to python, and I'm trying to understand the following line:
"".join(char for char in input if not unicodedata.category(char).startswith('P'))
Source: https://stackoverflow.com/a/11066443/3818487
This code removes all unicode punctuation from input. I don't understand why it works. As far as I can tell, it just iterates over all characters in input ignoring the punctuation characters. How can it access char before it is declared in the for loop? I come from a java background, so this is very confusing to me.