0

I am doing a chapter on modules and packages and my book says that to make a folder a package

it must also contain a special module called __ init__.py

I recently did some work on classes and I though __ init__ was used to initializes instances of a class, so what is it doing here?

Despereaux
  • 201
  • 2
  • 10
  • 1
    `__init__` is used as a name for the initialisation method of classes, *and* for the initialisation module of a package… – deceze Jul 30 '21 at 13:34
  • 1
    Strictly speaking, you don't any more. PEP-420 introduced implicit namespace packages that relaxed this particular requirement. See https://stackoverflow.com/a/37140173/1126841. – chepner Jul 30 '21 at 13:37
  • Yeh, I checked it out. I also tried running the programme without the __init__.py module and it worked fine. My book is just a bit outdated then... – Despereaux Jul 30 '21 at 13:39

0 Answers0