mardi 21 janvier 2020

Is the __init__.py really not necessary for python 3.7 packages?

Recently I created a flask application and decided to add a test folder outside the application folder (both the app and test folders are in the same directory). All the implementations I would be testing for are contained in packages and modules created in the app folder.

Having the __init__.py file in both folders work just fine as expected. However when I remove the __init__.py file from the test folder, I start to experience moduleImportError. Python doc says that the __init__.py file is no longer a requirement for packages in python 3.3+ but in my case here, seems it's a requirement. Can someone explain why it's so?

Aucun commentaire:

Enregistrer un commentaire