Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
how to compare two strings?
 

Index | Next | Previous | View Flat


phr-n2002a at nightsong

Feb 12, 2002, 1:13 AM


Views: 559
Permalink
how to compare two strings?

Is there any built-in function in Python for comparing two strings
alphabetically? Something suitable for passing as the optional
comparison function for the list "sort" method. I could code up
something like

def scmp(a,b):
if a<b: return -1
if b<a: return 1
return 0

but it's pretty ugly to need to do that. I've looked in the docs but
don't see any obvious counterpart to perl's lozenge (<=>) operator.
Is there one?

Thanks.

Subject User Time
how to compare two strings? phr-n2002a at nightsong Feb 12, 2002, 1:13 AM
    how to compare two strings? brian at sweetapp Feb 12, 2002, 1:23 AM
    how to compare two strings? martin at v Feb 12, 2002, 2:20 AM
        how to compare two strings? phr-n2002a at nightsong Feb 12, 2002, 2:38 AM
    how to compare two strings? scarblac at pino Feb 12, 2002, 6:47 AM
        how to compare two strings? martin at v Feb 12, 2002, 5:57 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.