Python Idiom Question
James Logajan
JamesL at Lugoj.Com
Mon Jul 9 20:38:21 EDT 2001
Tim Daneliuk wrote:
>
> What is the equivalent python idiom to the following 'C' code:
>
> while (x=getchar() != 'N')
> {
> Do something}
>
> In other words, is there a convenient way to simultaneously get
> input, from say, raw_input() or f.read(), and check the return
> value agains some logical construct, re pattern match, or whatever?
What is wrong with:
while 1:
x=raw_input()
if x == 'N': break
Do something
More information about the Python-list
mailing list