Hmm... An idea: if a,b==c,d:

Chad Netzer cnetzer at mail.arc.nasa.gov
Mon Nov 18 18:49:21 EST 2002


On Monday 18 November 2002 15:02, sismex01 at hebmex.com wrote:

> It's like comparing strings: first the first char,
> then the second, etc.

Exactly, and what makes it easy to remember is that list, tuple, and string 
comparison are all done in the same way:

def all_true( abc, abd, bvd ):
    return ( (abd > abc)
             and (abd >= abc)
            and (abd >= abd)
            and (not (abd > abd))
            and (bvd > abc)
            and (bvd >= abc) )

# Comparisons are the same using strings, tuples, or lists
print all_true( "abc", "abd", "bvd" )
print all_true( tuple("abc"), tuple("abd"), tuple("bvd") )
print all_true( list("abc"), list("abd"), list("bvd") )


-- 
Bay Area Python Interest Group - http://www.baypiggies.net/

Chad Netzer
cnetzer at mail.arc.nasa.gov




More information about the Python-list mailing list