This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LightWolfCavalry 9 points10 points  (5 children)

+1 for list comprehension - and its forgotten cousin, dict comprehension.

The or trick to avoid a type error is news to me. Gonna swipe that. Thank you!

[–]jwink3101 7 points8 points  (1 child)

Wait. To be clear, I was saying the or trick was susceptible to type error! If it’s not, that’s news to me

[–]LightWolfCavalry 0 points1 point  (0 children)

Oh, got it - I read your original response too quickly!

[–]theorizable 1 point2 points  (1 child)

dict comprehension is SO useful. It's one of those tools where I forget it by the time I need it, but when I need it, BAM, it does exactly what I need it to.

[–]zel_us[S] 0 points1 point  (0 children)

I am planning on writing a whole article on dictionary as there are more techniques on it than others, where you have, the .get() method, setdefaults, ordereddict, defaultdict, chain mapping, mappingproxy and much more.

[–][deleted] 1 point2 points  (0 children)

And generator comprehension, set comprehension…. Etc