开发者

How do I turn this into a one line generator?

My best attempts have failed:

for s in self.services:
  for m in s.messag开发者_如何学运维es: yield m


(m for s in self.services for m in s.messages)

... as counter-intuitive as it seems.


itertools.chain.from_iterable(s.messages for s in self.services)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜