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
  • 211,518
  • 52
  • 313
  • 390

1 Answers1

4

Inside __init__.py, do from bar import spam.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895