Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Bill
Steve D'Aprano wrote: In "any(v is None for v in values)", "any" probably isn't called until its argument is (fully) known. No, its a generator expression, so it provides the values one at a time, as needed. Okay, thank you for setting me straight. I'm only about 2 weeks down this road so

Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Steve D'Aprano
On Wed, 20 Sep 2017 10:07 pm, Steve D'Aprano wrote: > I'm not sure whether to be surprised or not. > > The first one only checks for identity, which should be really fast, while the > `is` operator tests for equality too, Oops, that's supposed to be `in`, not `is`. [...] > Ah... I see that Ro

Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Steve D'Aprano
On Wed, 20 Sep 2017 06:04 pm, Bill wrote: > Robin Becker wrote: >> On 16/09/2017 01:58, Steve D'Aprano wrote: >> >>> >>> If you want to test for None specifically: >>> >>> if any(v is None for v in values): >>> print "at least one value was None" >>> >> ... >> >> for some reason

Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Peter Otten
Bill wrote: > Robin Becker wrote: >> On 16/09/2017 01:58, Steve D'Aprano wrote: >> >>> >>> If you want to test for None specifically: >>> >>> if any(v is None for v in values): >>> print "at least one value was None" >>> >> ... >> >> for some reason that seems slow on my machine

Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Bill
Robin Becker wrote: On 16/09/2017 01:58, Steve D'Aprano wrote: If you want to test for None specifically: if any(v is None for v in values): print "at least one value was None" ... for some reason that seems slow on my machine when compared with if None in values:

Re: How do I check all variables returned buy the functions exists

2017-09-20 Thread Robin Becker
On 16/09/2017 01:58, Steve D'Aprano wrote: If you want to test for None specifically: if any(v is None for v in values): print "at least one value was None" ... for some reason that seems slow on my machine when compared with if None in values: . C:\usr\share\rob

Re: How do I check all variables returned buy the functions exists

2017-09-15 Thread Steve D'Aprano
On Sat, 16 Sep 2017 01:43 am, Ganesh Pal wrote: > I have a function that return's x variables How do I check if all the the > values returned are not None/False/0/'' [...] > value1, value2 , value3 = return_x_values() > > > # check if its not none > > # I think this can be better > if value1

Re: How do I check all variables returned buy the functions exists

2017-09-15 Thread Rob Gaddi
On 09/15/2017 08:43 AM, Ganesh Pal wrote: I have a function that return's x variables How do I check if all the the values returned are not None/False/0/'' Here is the same program to demonstrate this , but I felt this can be better any suggestions ? # vi file.py import random import stri

How do I check all variables returned buy the functions exists

2017-09-15 Thread Ganesh Pal
I have a function that return's x variables How do I check if all the the values returned are not None/False/0/'' Here is the same program to demonstrate this , but I felt this can be better any suggestions ? # vi file.py import random import string def return_x_values(): " returns x