[Tutor] __init__.py

Alan G alan.gauld at freenet.co.uk
Mon May 23 09:14:07 CEST 2005


HI Joseph,


> I've seen many (python) "plugins" (some located in site-packages
[windows
> here]) with the name __init__.py.

init.py is the file that controls the behaviour of python packages
- that is collections of modules used as a single entity.

Read the python docs for the fine detail, but essentially the init
file often imports functions or classes that the package designer
wants to appear as top level(in the package as opposed to being in
a sub module). Also initialisation of package variables such as
constants can be done there.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list