Idea:
Allow
import staff from module
syntaxes in addition to usual
from module import stuff
Motivation:
I often need import stuff from a module, so I write code like this
from pocket import ring
# some code using ring
As my code grows, I often realise that I need to import more stuff from the same module, so I change my code into.
import pocket
# some code using pocket.ring, pocket.nothing, pocket.hand
As Im finishing my code, I sometime come to conclusion that I dont need any other stuff from the module, so I clean my code back into
from pocket import ring, nothing, hand
# some code using ring, nothing, hand
I make these edits back and forth multiple times during the development. Each of this edits require me to flip the order of import
and pocket
, which requires copy-pasting or deleting-and-rewriting the symbols. Therefore, I suggest to allow writing
import ring from pocket
and
import ring, nothing, hand from pocket
so the order of ring
and pocket
would always remain the same, and I could save a few keystrokes
Cost/Benefit analysis
I do realise that the benefits from my suggestion are extremely small, but cost should not be very hight either, right? The implementation should not break anything, does not add anything new…
My hope is that the rest of the developers will come out saying “damn, I hated the same thing all along, lets change this!”