What is __path__ useful for?

Posted by Jason Baker on Stack Overflow See other posts from Stack Overflow or by Jason Baker
Published on 2010-04-23T14:22:27Z Indexed on 2010/04/23 14:23 UTC
Read the original article Hit count: 205

Filed under:
|
|

I had never noticed the __path__ attribute that gets defined on some of my packages before today. According to the documentation:

Packages support one more special attribute, __path__. This is initialized to be a list containing the name of the directory holding the package’s __init__.py before the code in that file is executed. This variable can be modified; doing so affects future searches for modules and subpackages contained in the package.

While this feature is not often needed, it can be used to extend the set of modules found in a package.

Could somebody explain to me what exactly this means and why I would ever want to use it?

© Stack Overflow or respective owner

Related posts about python

Related posts about module