Q:

python module organisation

I am writing a python library that backs up and organises scientific data. lets call it dataapp
I would like to lay out my directory as follows:
core/
operations/
cli_interface.py

core contains all the data classes and the class for a data repository, and all the code is standalone, with no dependancies. operations contains all of the actions, like saving, updating, backing up data, operations does however depend on core. core is not a child of operations and should have the ability to be used on its own.
However importing code from core into operations seems like an ugly thing because I would have to import from relative paths and from the parents.
Another option for importing is for install dataapp on the machine globally, in that case operations can import from core easily.
My question is: is the above recommended, or is there a better way to lay out my code?

A:

Try this layout:
core/
    __init__.py
    functions.py

operations/
    __init__.py
    actions.py

test.py

Note: __init__.py files, they are just empty files to define package with a name coincided with the directory name.  
Where functions.py with core functions defintions:
def core_function():
    print "core function"

Module actions.py will have such connection with core:
from core import functions

def simple_action():
    functions.core_function()

In your applicationtest.py you could use it as follows:
from core import functions
from operations import actions

functions.core_function()
actions.simple_action()

Note also: that core and operations packages are referenced by whole path - not relative, i.e. if you had lab.sci.core structure you'd use from lab.sci.core and from lab.sci.operations import commands in your test.py application and actions.py module.

