Importing classes/functions with same name as module

Viewed 4247

Say I use a python package with the following structure:

package/
   bar.py
   foo.py
   __init__.py

bar.py contains the class bar and foo.py contains the function foo. When I want to import the function/class do I have to write

from package.bar import bar
from package.foo import foo

or can I write

from package import bar
from package import foo

More generally asked: Can I always omit the class/function name, when I import a module with the same name as the class/function?

1 Answers
Related