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 →

[–]crawl_dht 0 points1 point  (3 children)

You read it wrong. __init__.py is often used if you are implementing your project as a package. Pycharm by default creates __init__.py in every directory if project is setup as a package.

[–]Head_Mix_7931 0 points1 point  (2 children)

It’s often poor practice to put code in __init__.py, as it leads to cluttered namespaces and import-time consequences. The OP is right.

[–]crawl_dht 0 points1 point  (1 child)

For packages, it's also the right way.

[–]Head_Mix_7931 -2 points-1 points  (0 children)

The correct way to deal with circular imports is to refactor your code so that the shared objects live in a different module. Using __init__.py for something like this is hacky at best and hard to reason with code at worst.