Use dot notation to call a function without using parentheses

Walk More walkmore99 at gmail.com
Tue Dec 22 07:15:53 EST 2020


On Tuesday, December 22, 2020 at 6:31:08 AM UTC-5, Python wrote:
> Walk More wrote: 
> > I am trying to use dot notation to call a function without using parentheses, see code section with *** 
> > I have looked into SimpleNamespace, namedTuple, dataclass... but no luck. 
> > Below is my sample code to date. 
> > Any suggestions?
> accessors. 
> 
> class myClass: 
> @property 
> def data(self): 
> print('read data attribute') 
> return self._data 
> @data.setter 
> def data(self, value): 
> print('write data attribute') 
> self._data = value 
> def __init__(self, data=None): 
> self.data = data 
> 
> o = myClass('spam') 
> 
> print(o.data) 
> 
> o.data = 'ham' 
> 
> output: 
> 
> write data attribute 
> read data attribute 
> spam 
> write data attribute


Python,
Thank you very much for your solution.





More information about the Python-list mailing list