Python Forum
Why can package names differ from module name?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why can package names differ from module name?
#1
I am new to Python/Django, so maybe I do get something terribly wrong.

I was handed a project without complete requirements.txt and needed to install the modules/packages needed.

It wasn't that hard to find out that 'dal' actually is the package 'django autocomplete light'

Then I was looking for "filters" and found a bunch of modules. But the package name of the module "filters" acutally was "filter"...WTH, why would I choose such a different name?

The real problem was 'menu'. I found a 'menu' package, error was gone and I was happy, everything worked fine. Exported requirements, imported on new machine and it was broken. What happened: I installed "menu" package, "django-simple-menu" later orverwrote the folder. On the new machine, obviously "django-simple-menu" was installed first, wrong "menu" package overwrote it and broke the project.

To me, naming the package and module differently feels like "worst practice" and I am surprised it is even allowed.
Reply
#2
You look to be using an abandoned 3rd party module which anything can happen then. I have never used those specific modules. But looking at their github pages it looks to be somewhat abandoned. From the guithub page it hasnt been worked on in years. Their read the docs page has a date of 2014 on it. So my best guess is they stopped their work around then. So if there were issues, they would not be fixed.

menu package on the other hand has commits from 2 years ago to 4 months ago.

If both packages were being maintained they might change things because of the other. But that is not the case.
Recommended Tutorials:
Reply
#3
(Sep-23-2019, 12:17 PM)PlanB Wrote: naming the package and module differently feels like "worst practice"
actually package can (and almost always) will have many modules, or even sub-packages. So it's not possible to always have package and module with the same name
read https://docs.python.org/3/tutorial/modul...l#packages
given your source code imports it should be easy to distinguish between package, subpackages and modules
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Thanks, I understand there might be submodules, but it would be helpful if the created folders at least have a unique name. I might want to use more than one filter package - which might do totally different filterings - but will then need to care about conflicts on my own - right?
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020