Writing python libraries: best practices for naming and import management

Let's say I need to write some small and medium libraries for my company.

Does the Putin way make sense to use the Java approach and prefix all of them with a common high-level package (gem, module), such as achieving the following structure:

mycompany.mylibrary1.moduleA
mycompany.mylibrary1.moduleB.moduleD
mycompany.mylibrary2.moduleC

or better to just go:

mylibrary1.moduleA
mylibrary1.moduleB.moduleD
mylibrary2.moduleC

I see that the second approach is used most of the time, but I was looking for confirmation (or not) that way.

I could not find anything in this regard in PEP 008 , next to:

The Python library naming conventions are a bit messy, so we'll never get this fully consistent [...]

, , .

, - , , ( , , ).

Java, namespaces , , pythonic..., ?

PS. " " SO, Python PEP , , ! ... .

+5
1

python. (, , , , , , , ..), , , "" . ,

import foo.bar
e = foo.bar.make_entity()

,

from foo.bar import make_entity
e = make_entity()

, , . "com.example.some.lib.module.frobnicate() . , .

+5

All Articles