<p>What's the best Python idiom for this C construct?</p>

<pre><code>while ((x = next()) != END) {
    ....
}
</code></pre>

<p>I don't have the ability to recode next().</p>

<p>update:  and the answer from seems to be:</p>

<pre><code>for x in iter(next, END):
    ....
</code></pre>

Maybe it's not terribly idiomatic, but I'd be inclined to go with
```
```
x = next()
while x != END:
    do_something_with_x
    x = next()
```
```
... but that's because I find that sort of thing easy to read