문제

I have a package structure as follows (which is built by cookiecutter using this template):

project
    <package-name>
         __init__.py
         <package-name>.py
README.rst
LICENSE
setup.py
...

There is a class inside .py which is Foo

After installing it into a virtualenv with easy_install, I can access to the class

from <package-name>.<package-name> import Foo

I wonder how I can access FOO by from <package-name> import Foo.

도움이 되었습니까?

해결책

You can, by importing everything from <package-name> into the __init__.py file; add a line:

from .<package-name> import *

in the __init__.py module.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top