bsddb: must bsddb write a file ?
Skip Montanaro
skip at pobox.com
Thu Jun 14 17:24:35 EDT 2001
Florian> bsddb used as a binary- tree has a .last()-methode to get the
Florian> element with the biggest key. there is no such funktion in the
Florian> build in hash-table. that was the reason switching to bsddb
Alphabetically biggest or longest? If you mean alphabetically, this should
work:
keys = dict.keys()
keys.sort()
keys[-1]
If you mean the longest key, this should work:
keys = dict.keys()
keys.sort(lambda x,y: (cmp(len(x),len(y) or cmp(x,y))))
keys[-1]
Both only have meaning if you are using strings as keys.
--
Skip Montanaro (skip at pobox.com)
(847)971-7098
More information about the Python-list
mailing list