Does there exist a way in Python 2.7+ to make something like the following?
{ something_if_true if condition else something_if_false for key, value in dict_.items() }
I know you can make anything with just 'if':
{ something_if_true for key, value in dict_.items() if condition}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…