M
M
mkone1122020-12-14 00:21:16
Django
mkone112, 2020-12-14 00:21:16

Are empty __init__.py needed?

As of Python 3.3+, `__init__.py` is no longer required to indicate that a directory is a package. But Django, when creating projects and applications, still creates these files, if they are deleted - the project works as if nothing had happened. But why do I need these files if I don't plan to add logic there? Maybe it's better to remove them, guided by YAGNI(KISS?)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-12-14
@pyHammer

mkone112 do they bother you a lot? I don't)
And here's another thing, let's think, here you do not want to add logic to __init__, but in another place you want to add, and then what?
I completely agree with Ruslan Gilfanov , I do it myself. If you don’t define apps.py inside the application, then it’s trite even to not declare signals. Therefore, for me, the __init__.py file with such content is the default template.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question