Note that there are some explanatory texts on larger screens.

plurals
  1. PODo you need to use __init__.py to import a class from a module within a package cleanly?
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThere isn't any way to make `import Foo` import a class and not a module. What you said in your last paragraph is on the right track. Why do you feel you need a package for this? If you just use a module then `from foomodule import Foo` is brief enough.
      singulars
    2. COthat makes sense. i guess it just seems like keeping things in packages is a neat idea.maybe i was thinking about a package where the class itself relies on other modules and maybe even sub packages within it, and being able to just get that class imported. for instance if i have a package for connecting to a db in sql alchemy, and the class uses models imported from modules within the package.
      singulars
    3. COThe more stuff you have in your package, the less sense it makes to have `import package` magically import just one of those things instead of importing the actual package. If you need a package to hold multiple modules, great, but then you need to say which modules you want to import, or what stuff you want to import from each. Just try doing it the normal Pythonic way with an appropriate naming scheme. I think you'll find it's not actually that much of a hardship to do `from foomodule import Foo` once at the top of your program.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload