Hello,
please may I ask how do you approach working with foo_module
from different locations in following situation?
/project
├── foo
├── foo_module
├── bar
├── bar_module
├── baz
Lets assume foo_module
have some enums, constants, functions that should be used from all inner component modules / parameters (lets say that in this scenario it doesn’t make much sense to make them part of an extension, but rather a shared module).
This approach is nicely described by @tekt in his article
- Start by putting things within the specific component where they’re needed, perhaps as methods of an extension class that’s defined inside a particular component.
- If you have a specific need to use it somewhere else, then pull it up to a level that contains both of those things. That might mean creating a shared module that’s specific to some portion of the project that contains the components that need it, or it might mean a project-wide shared module.
For example when in bar_module
, one could work with foo_module
like this, but I am not sure if there isn’t some better way of doing so?
foo_module = mod('../foo_module')
foo_module = mod(parent.Foo.op('foo_module'))
foo_module.foo()
Also when working with parameter expressions in baz, I am guessing one would have to use similar syntax:
mod('../../foo_module').CONST
mod(parent.Foo.op('foo_module')).CONST
My question is whether there is some better approach to this situation, or whether there is some way to make the expressions shorter / more readable? I know DAT modules can’t be organized to packages based on wiki:
Also note that DAT modules cannot be organized into packages as regular file system based python modules can be.
But I was wondering whether there might be a way to access foo_module
using something like this:
import foo.foo_module
foo.foo_module.foo()
foo.foo_module.CONST
Thanks
Edit: Related to this thread