3 ms·
The single worst part of Python import for me is "from". I think "from" was a mistake, and should never have been added. Like many "pythonism" its just another
by svnpenn 4y ago
The single worst part of Python import for me is "from". I think "from" was a mistake, and should never have been added. Like many "pythonism" its just another layer of sugar thats not needed, and is only marginally useful. Especially when dealing with new packages, its essentially trial and error for me with:
import hello
from hello import world
import hello.world
from hello import world.bye
from hello.world import bye
I didn't realize until I went to Go, where "from" doesn't exist, how much I hated it with Python.
- DangitBobby 4y agoYeah, being forced to understand the layout of the code you're importing from isn't great. Python imports could have been designed to just do the right thing. But explicit is better than implicit, amirite?
- int_19h 4y agoWould you rather write "hello.world.bye" every time you need it?
- Jensson 4y agobye = hello.world.bye
- eesmith 4y agoimport hello.world.bye as bye
- deleted 4y ago[deleted]
- 41b696ef1113 4y agoI appreciate the explicitness, so indeed I would.
- yjftsjthsd-h 4y agoThen do that? Is there anything forcing you to use from? Edit: While opinionated, it's a real question; in my fairly simple use of Python, I have never hit a use of "from" that couldn't have been a plain "import", but if I'm missing a case feel free to correct me.