I am unsure how to phrase the question I am asking so feel free to change the title.
Currently, I am working on an existing python codebase and came across this "style" and hope to understand the benefits for using it.
for example,
Class Pokemon(object):
def __init__(self, name):
self.name = name
def _catch(self, pokeball):
''' actual implementation here'''
def catch(self, pokeball):
_catch(pokeball)
You may notice that calls to the catch() function will be rerouted to the _catch() function. I understand that an underscore before a function could be meant to prevent accidental overriding of the function.
EDIT: I think the title should be modified again, I understand what the underscores mean however I was unsure of why we use a catch() and _catch() as we obviously want to expose the function with catch() but decide to stick the implementation within _catch().
Aucun commentaire:
Enregistrer un commentaire