dimanche 24 novembre 2019

Redundant Function Call in Python

So I was looking at a certain class which has the following property function. However, the property method itself doest describe the proceduce instead calls another function to do so as follows:

class Foo():

 @property
 def params(self):
     return self._params

 @property
 def target(self):
     return self._target

 def _params(self):
     return print("hello")
 def _target(self):
     return print("world")

What I am trying to understand if it is somesort of pattern? I have seen similar thing in another class as well where the method with property decorator simply calls another method of same name with understore in the beginning.

Aucun commentaire:

Enregistrer un commentaire