Author steven.daprano
Recipients brandon-rhodes, docs@python, steven.daprano
Date 2014-07-11.15:03:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> 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
  your problem
* 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.
Date User Action Args
2014-07-11 15:03:17steven.dapranosetrecipients: + steven.daprano, brandon-rhodes, docs@python
2014-07-11 15:03:17steven.dapranosetmessageid: <>
2014-07-11 15:03:17steven.dapranolinkissue21956 messages
2014-07-11 15:03:17steven.dapranocreate