Hacker News new | comments | show | ask | jobs | submit login

Import several files into one, then import it elsewhere.



E.g. I have file aaa.py, bbb.py and ccc.py (placed in the same directory but I don't mind adding a line of code to declare their relationship explicitly). What I want is not only to be able to import them all at once in ddd.py but to access everything from aaa and bbb in ccc, everything from bbb and ccc in aaa and everything from aaa and ccc in bbb [almost] seamlessly.


You could create a __init__.py file that imports everything from each of those files:

    from .aaa import *
    from .bbb import *
    from .ccc import *
Then in each of the other files (aaa.py, etc) put:

    from . import *


Thats a circular import and thus not guaranteed to work.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: