Skip to content Skip to sidebar Skip to footer
Showing posts with the label Idioms

Self-referencing Ternary

I've been doing this for a while: x = x if x else y In all sorts of contexts where x might be … Read more Self-referencing Ternary

What Is The Right Python Idiom For Sorting By A Single Criterion (field Or Key)?

As in title, how can I sort objects by single criterion? I've heard about key parameter, cmp pa… Read more What Is The Right Python Idiom For Sorting By A Single Criterion (field Or Key)?

What's The Idiomatic Python Equivalent Of Get() For Lists?

Calling get(key) on a dictionary will return None by default if the key isn't present in a dict… Read more What's The Idiomatic Python Equivalent Of Get() For Lists?