Adios' Notes

« Back to posts
  • Viewed
    times

Filed under

  • python
November 2, 2009

What is __init__.py used for?

  • Edit
  • Delete
  • Tags
  • Autopost

Files named __init__.py are used to mark directories on disk as a Python package directories. If you have the files

mydir/spam/__init__.py
mydir/spam/module.py

and mydir is on your path, you can import the code in module.py as:

import spam.module

or

from spam import module

via effbot.org

Tweet
  • 0 responses
  • Like
  • Comment