[docs] [issue21956] Deleted document should not appear in 3.4 docs
report at bugs.python.org
Fri Jul 11 17:03:17 CEST 2014
Steven D'Aprano added the comment:
> in many cases flat-out wrong
What advice is "flat-out wrong"? All the advice seems excellent to me:
* avoid "from spam import *" (with a very few exceptions)
* be cautious about "from spam import eggs"
* avoid bare "except" clauses
* watch out for "time from check to time to use" race conditions
(e.g. prefer EAFP over LBYL when opening files)
* don't reinvent the wheel poorly when the std lib already solves
* avoid backslash as line continuation
> It should be deleted as soon as possible.
Why delete it rather than fix any (alleged) problems with it?
> The advice is currently being debated on Twitter and people
> are sad that they are supposed to stop using “from foo import bar”
Debated on Twitter. Why am I not surprised that they've misunderstood it?
The document explains why "from foo import bar" can *sometimes* be harmful. The wording could be improved, and isn't as clear as it should be, but the advice is broadly correct: "from foo import bar" injects the object bar into the current namespace, not the name, which means that if foo rebinds bar, that change will not be seen in the current namespace. If foo never rebinds bar, then there is no problem, but if bar is a *variable* rather than a (pseudo-)constant, you may run into subtle and tricky problems.
-1 on deleting.
If the consensus is to keep it, I'll look at rewording and improving some of the weaker descriptions.
Python tracker <report at bugs.python.org>
More information about the docs