What is __path__ useful for?

后端 未结 4 1977
长情又很酷
长情又很酷 2020-11-28 03:57

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

Packag

4条回答
  •  余生分开走
    2020-11-28 04:33

    If you change __path__, you can force the interpreter to look in a different directory for modules belonging to that package.

    This would allow you to, e.g., load different versions of the same module based on runtime conditions. You might do this if you wanted to use different implementations of the same functionality on different platforms.

提交回复
热议问题