TIL about Python List Comprehensions. I came across code that looked like this in a codebase.

 baz = [foo.bar for foo in foos] 

I could see what was happening (baz is now a list of bar for each object in foos). I didn’t know this was called list comprehension but now I understand the data structure.

List comprehensions are useful for lots of things when you want to create lists from other objects (docs source).