python module resides in a repository whose name contains dash characters
Question: I know name of the module should not have a dash.

Here is my repository structure

    
    
    my-repo-name/
         src/ 
         tests/
            __init__.py
            tests.py
         fab/
            __init__.py
            fabfile.py
    
         README.rst
         __init__.py
    

In my tests, I need to import fabfile.py to run a test. But because the name
has a dash, I can't do `from my-module-name.fab.fabfile import X,Y,Z` or
relative import because it's a non-package.

Any recommendation how to do this without hacking with `__import__(...)` or
adding it to the sys path? Should I just add another directory?


Answer: Use [`importlib.import
module`](http://docs.python.org/library/importlib.html#importlib.import_module):

    
    
    import importlib
    fabfile = importlib.import_module('my-repo-name.fab.fabfile', None)
    X = fabfile.X
    

But you should really just change the name of the repository. To transition,
you can create a temporary [symlink](http://en.wikipedia.org/wiki/Symlink)
with

    
    
    $ mv my-repo-name my_repo_name
    $ ln -s my_repo_name my-repo-name
    

