Reputation: 2107
My best attempts have failed:
for s in self.services:
for m in s.messages: yield m
Upvotes: 0
Views: 197
Reputation: 107686
itertools.chain.from_iterable(s.messages for s in self.services)
Upvotes: 3
Reputation: 61635
(m for s in self.services for m in s.messages)
... as counter-intuitive as it seems.
Upvotes: 7