When I program using the C++ language, I use the following while
loop pattern quite often.
while ((Data data = GetNewData()) != END) {
// Do some processing
ProcessData(data);
}
How can we do the same thing in Python? It seems like the following doesn't work.
while (data = GetNewData()) != END:
# Do some processing
ProcessData(data)
Then one alternative I can think of is the following.
while 1:
data = GetNewData()
if data == END:
break
# Do some processing using data
ProcessData(data)
But the above doesn't look neat. Could anyone suggest a good way?