Python: 'Private' module in a package

前端 未结 5 778
小蘑菇
小蘑菇 2020-12-05 06:23

I have a package mypack with modules mod_a and mod_b in it. I intend the the package itself and mod_a to be imported free

5条回答
  •  既然无缘
    2020-12-05 07:05

    I prefix private modules with an underscore to communicate the intent to the user. In your case, this would be mypack._mod_b

    This is in the same spirit (but not completely analogous to) the PEP8 recommendation to name C-extension modules with a leading underscore when it’s wrapped by a Python module; i.e., _socket and socket.

提交回复
热议问题