Let's say I want to set the default value of an argument of a method of a class to the value of some data attribute of the class. What is an appropriate way to do this? Is there a way to do this using lambda functions?
Here is some example code:
class A(object):
def __init__(
self
):
self._defaultReportText = "hello world"
def report(
self,
text = self._defaultReportText
):
return(text)
Obviously, the default value specification for the argument text
of the method report
does not work here because self
is not defined at this point. How should I make this value available?