Python Idiom Question

Tim Daneliuk tundra at tundraware.com
Mon Jul 9 19:41:35 EDT 2001


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?

I'm sure this is possible, I just cannot seem to find the magic
combination that gets me there.  Nothing seems to turn up when I
look in the Usual Places, but then again, I may not be Lookin' Right.

At the moment, I'm doing things like:

x=raw_input()
while x:
	Do Something Interesting
	x = get_input("Prompt: ")

TIA,
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com



More information about the Python-list mailing list