[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I check all variables returned buy the functions exists

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 strings for further processing"
    value1 =  random.choice(string.ascii_letters)
    value2 = random.choice(string.ascii_letters)
    value3 = random.choice(string.ascii_letters)
    return (value1, value2, value3)

#unpack them

value1, value2 , value3 = return_x_values()

# check if its not none

# I think this can be better
if value1 and value2 and value3 :
   print "continue with the program"

  print "Exting the program"

# python file.py
continue with the program

I  am a Linux user with Python 2.7