<s>[INST] if/else in Python's list comprehension? How can I do the following in Python?
row = [unicode(x.strip()) for x in row if x is not None else '']

Essentially:

replace all the Nones with empty strings, and then
carry out a function.

 [/INST] You can totally do that, it's just an ordering issue:
[ unicode(x.strip()) if x is not None else '' for x in row ]

Note that this actually uses a different language construct, a conditional expression, which itself is not part of the comprehension syntax, while the if after the forâ¦in is part of list comprehensions and used to filter elements from the source iterable.
 </s>