3

I've got a package like this:

 foo/
    __init__.py
    bar.py
    baz.py

I'd like to have submodules' functions automatically available when I import foo. So if bar.py has def spam() somewhere, I'd like to be able to call it directly like foo.spam(). What would be the best way to achieve that?

georg
  • 204,715
  • 48
  • 286
  • 369

1 Answers1

4

Inside __init__.py, do from bar import spam.

Daniel Roseman
  • 567,968
  • 59
  • 825
  • 842