如果我有对象
>>> class example_class():
>>> def example_function(number, text = 'I print this: '):
>>> print text, number
我可以更改example_function输入参数
>>> example_instance = example_class()
>>> print example_instace.example_function(3, text = 'I print that: ')
现在,我希望每次使用I print that:
时始终使用example_instace
。是否可以更改text
的默认值,以便我得到此行为:
>>> example_instace = example_class()
>>> print example_instance.example_function(3)
I print this: 3
>>> default_value(example_instance.text, 'I print that: ')
>>> print example_instance.example_function(3)
I print that: 3