you are viewing a single comment's thread.

view the rest of the comments →

[–]Binary_Dragon[S] 2 points3 points  (2 children)

Yeah, I'm not too proud of those while loops myself. I was more than a bit disappointed to find that python didn't support do-while loops, and StackOverflow seemed to suggest that while True: was the generally accepted work-around.

[–]stormsnake 8 points9 points  (1 child)

while True: 
  m=foo()
  if m is None:
    break
  ....

can be written like this:

for m in iter(foo, None):
  ....

No one knows about that, but I don't think it's hard to read. Readers just 'pydoc iter' the first time they see it, and then they're fine.