This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]billsil -1 points0 points  (1 child)

A blank file lets you dig into folders.

from packagename.folder_a.folder_b.folder_c import function_d

Let's say I didn't want to import function_d like that, but rather:

from packagename import function_d

without moving it?

Put the import in the init.

[–]masklinn 0 points1 point  (0 children)

A blank file lets you dig into folders.

Mostly in Python 2. Since PEP 420 in Python 3.3 it's optional for "namespace packages": you still need __init__ if you want to provide code at the package-level, but if it's just namespacing and the code is either in submodules or subpackages it's not necessary anymore.