import as (Re: Clashing cmp)
Greg Ewing
greg.ewing at compaq.com
Wed Sep 29 17:23:02 EDT 1999
Andrew Dalke wrote:
>
> # "cmp" module compares two files using the cmp() function.
> # Work around an ugliness in Python since cmp() is also a builtin!
> old_cmp = cmp
> from cmp import cmp
> file_compare = cmp
> cmp = old_cmp
This strikes me as an excellent argument in favour of
having some sort of "import as" statement.
Such a beast has been suggested before, but argued against
on the basis that you can just as well import and then
assign to a new name.
But if you're renaming because of name clashes, that can
be quite ugly, as the above example shows.
Greg
More information about the Python-list
mailing list