I'm pretty much just doing this...
while not something():
pass
But I want the function something() to return another value other than True or False, specifically a list. In C I'd just return it by plugging in a reference as a parameter but Python doesn't seem to like doing things that way. Therefore in the something() function I would obviously just return 2 values. I'm ok with that. The issue I have is that the code with the while loop doesn't look elegant and so I presume there must be a better way.
In C:
int a[2];
while(!something(a)); //presume that 'a' updates and the loop breaks
In Python:
bool_value, a = something()
while not bool_value:
bool_value, a = something()
I know it's not such a big deal but just the fact that I have to write the same line twice seems a bit bad. Is there some sort of syntax I can use to call the function and return the 'a' all within the while line?
while True:
bool_value, a = something()
if not bool_value:
break
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With