If I have an object that has several internal functions that are not exactly meant for outside calls. Should I always start them with _ or __?
It is indicated by PEP-8 that you should use a single underscore to indicate that these should be of internal use:
In addition, the following special forms using leading or trailing underscores are recognized (these can generally be combined with any case convention):
_single_leading_underscore: weak "internal use" indicator. E.g.from M import *does not import objects whose name starts with an underscore.
Double leading underscores can also be used but, those are subject to name mangling:
__double_leading_underscore: when naming a class attribute, invokes name mangling (insideclass FooBar,__boobecomes_FooBar__boo).
so be aware of that fact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With