R
Robert Ferrell
I have a style question. I have a class with a method, m1, which
needs a helper function, hf. I can put hf inside m1, or I can make it
another method of the class. The only place hf should ever be invoked
is from inside m1.
Is either style preferred?
Here are two short examples:
Helper function as method:
class K(object):
def _hf(self):
print 'Yo'
def m1(self):
self._hf()
return
Helper function as "private" function inside m1.
class K(object):
def m1(self):
def hf():
print 'Yo'
hf()
return
Opinions greatly appreciated.
thanks,
-robert
needs a helper function, hf. I can put hf inside m1, or I can make it
another method of the class. The only place hf should ever be invoked
is from inside m1.
Is either style preferred?
Here are two short examples:
Helper function as method:
class K(object):
def _hf(self):
print 'Yo'
def m1(self):
self._hf()
return
Helper function as "private" function inside m1.
class K(object):
def m1(self):
def hf():
print 'Yo'
hf()
return
Opinions greatly appreciated.
thanks,
-robert