I was in some code I haven’t visited in a while. And I came upon something I coded months ago.
It used a list comprehension to test every element of a list. If the result was empty, it signaled an error. Otherwise, it used result[0].
Gah! That’s so retarded! Was I asleep when I wrote that?
I changed it to a generator expression with a .next(), within a try/except on StopIteration.
One fewer line of code, and it’s faster.
I felt good.