In C++, I often use the following pattern:
while (int i = getNextElementPlease()) {
printf("%d\n", i);
}
But in python I have to repeat call twice:
i = getNextElementPlease()
while (i):
print(i)
i = getNextElementPlease()
How to avoid duplication of getNextElementPlease
?