python - Emulating a pass in a ternary operator? -


i'm creating list comprehension grab list of keys dictionary, ignoring specified ones.

[x if x not in ignorekeys else none x in entity] 

i'm using else none way of not appending ignored keys, ideally list comprehension pass on iteration. unfortunately pass gives syntax error, i'm wondering if there might way can emulate pass functionality?

you don't need else @ all, use if :

[x x in entity if x not in ignorekeys] 

this returns values not in ignorekeys.


Comments