The import * should not used if possible, I totally agree on that point,
but there's no need to rename namespaces for that.
br
Jean-Michel
Technically, no. But we're dealing with people, who are notoriously
*un*technical in their behavior. A person is much more likely to
develop bad habits if the alternative means more work for them. The
reason people do `from foo import *` is that they don't want to type
more than they have to. If they can write a one or two letter
namespace, they're likely to be happy with that trade-off. If the
alternative is to write out long module names every time you use a
variable, they'll tend to develop bad habits. To paraphrase Peter
Maurin, coding guidelines should have the aim of helping to "bring about
a world in which it is easy to be good."
I don't really see much problem with renaming namespaces: For people
reading the code, everything is explicit, as you can just look at the
top of the module to find out what module a namespace variable
represent; the local namespace doesn't get polluted with God knows what
from God knows where; and code remains succinct.
I've found in my own code that using, for example, the name `sqlalchemy`
in my code means that I have to go through painful contortions to get
your code down to the PEP-8 recommended 80 characters per line. The
resulting mess of multi-line statements is significantly less readable
than the same code using the abbreviation `sa`.
Do you have an argument for avoiding renaming namespaces? So far the
only example you provided is a code fragment that doesn't run. I don't
disagree with you on that example; referring to numpy as np without
telling anyone what np refers to is a bad idea, but no functioning piece
of code could reasonably do that.
Cheers,
Cliff