How to retrieve a module's path?

后端 未结 20 2045
无人及你
无人及你 2020-11-22 05:34

I want to detect whether module has changed. Now, using inotify is simple, you just need to know the directory you want to get notifications from.

How do I retrieve

20条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 06:03

    import module
    print module.__path__
    

    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.

    Source

提交回复
热议问题