Python modules run function from file
Question: I have a python (2) project with this structure:

    
    
    alerter
    │   README.txt
    │   __init__.py
    │   __init__.pyc
    │
    └───lib
            Alarm.py
            Alarm.pyc
            __init__.py
            __init__.pyc
    

in `lib.__init__.py` I have a function that I want to call from
`lib.Alarm.py`. If I just call it in `Alarm.py` I get this error:

    
    
    NameError: global name 'openDatabase' is not defined
    

Now I tried almost all imports at the top of the `lib.Alarm.py` file:

  * `from lib import openDatabase`
    
        ERROR: ImportError: No module named lib
    

  * `from alerter.lib import openDatabase`
    
        ERROR: ImportError: cannot import name openDatabase
    

Anyone an idea what I might try?


Answer: Try this:

    
    
    from alerter import lib
    lib.openDatabase()
    

(You don't state your Python version, which could be relevant.)

