Difficulty with `cmp', still

Fredrik Lundh fredrik at pythonware.com
Tue Sep 21 17:15:31 EDT 1999


François Pinard <pinard at iro.umontreal.ca> wrote:
> # Return the comparison value of two versions, of two file names with versions.
> def compare_versions(a, b):
>     a0, a1, a2, a3, a4 = _weights(a)
>     b0, b1, b2, b3, b4 = _weights(b)
>     print dir(__builtins__)
>     cmp = __builtins__.cmp              # because of `import cmp' above
>     return cmp(a0, b0) or a1 - b1 or a2 - b2 or a3 - b3 or a4 - b4

use "__builtin__", not "__builtins__".

and you have to import it, just like
any other module.

</F>





More information about the Python-list mailing list