1

Imagine I have a python package called foo, inside are many modules bar1, bar2...

I can access its functions after calling

import foo

and then with

foo.bar1.some_function()

Now there are a few functions that are general for the whole package foo. I would like to access it as module foo, that I can call its functions with

foo.some_often_used_function()

but then foo would be a module and not a package, it can't be both at the same time.

Is there some workaround to enable this syntax? Using python 3.11

Kaisky
  • 71
  • 4

1 Answers1

1

I managed to solve the issue by writing the functions direclty in init.py. Or in init.py

from foo.foo import *

and then have the functions in

foo/foo.py
Kaisky
  • 71
  • 4