I would like to know which would be more pythonic way to write python code using _ in modules, classes and methods.
Example 1:
import threading as _threading
class Thread(_threading.Thread):
pass
vs
from threading import Thread
class MyThread(Thread):
pass
on module level does it make sense to introduce private vars in methods like this:
def my_module_method():
_throw = foo + bar
return _throw
vs
def my_module_method():
throw = foo + bar
return throw
Am I correct to assume that best usage of private name would be to prevent instance of the class to use some private temp method eg:
class MyClass(object):
_my_internal = 0
def _do_not_use_me()
pass
so that enduser of that class would know not to use those methods directly in:
foo = MyClass._do_not_use_me()
bar = MyClass._my_internal
Any other advice on general usage of private names would be highly appreciated.