News for hackers. Stuff that matters.
Re:Traps for the Unwary in Python’s Import System by svnpenn on Wednesday August 17, 2022 @06:04PM (#32502309)
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.
Re:Traps for the Unwary in Python’s Import System by int_19h on Wednesday August 17, 2022 @08:26PM (#32503665)
Would you rather write "hello.world.bye" every time you need it?
Re:Traps for the Unwary in Python’s Import System by 41b696ef1113 on Wednesday August 17, 2022 @11:00PM (#32504740)
I appreciate the explicitness, so indeed I would.
Re:Traps for the Unwary in Python’s Import System by yjftsjthsd-h on Wednesday August 17, 2022 @11:53PM (#32505064)
Then 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.

Re:Traps for the Unwary in Python’s Import System by Jensson on Wednesday August 17, 2022 @09:57PM (#32504296)

    bye = hello.world.bye
Re:Traps for the Unwary in Python’s Import System by eesmith on Thursday August 18, 2022 @01:07AM (#32505531)

  import hello.world.bye as bye
Re:Traps for the Unwary in Python’s Import System by DangitBobby on Wednesday August 17, 2022 @07:54PM (#32503406)
Yeah, 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?
Re:Traps for the Unwary in Python’s Import System by svnpenn on Wednesday August 17, 2022 @07:57PM (#32503426)
Re:Traps for the Unwary in Python’s Import System by kastagg on Wednesday August 17, 2022 @08:18PM (#32503593)
What is the right thing?