Suppose you have a class in test.py
class test:
def method1(self, arg1, arg2):
# do some stuff and call utils_func(arg1, arg2)
utils_func
is only used within method1
. I am wondering which one of the following is more appropriate:
-
Define
utils_func
as a method fortest
. I'm not sure if this makes much sense since it doesn't directly operate on any attribute ofmethod1
. -
Don't do #1, but define
utils_func
withintest.py
so that you don't have to import it.
#3) Do #2, but define utils_func
in a separate file, e.g., utils.py
and then import it in test.py
.
I think this question is partly opinion-based, but I'm wondering if there's any standard way to do this for Python development, and what things I should consider when making a decision?
Aucun commentaire:
Enregistrer un commentaire