Python Forum

Full Version: Why can package names differ from module name?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
(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
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?