On 20/12/17 21:39, Stefan Ram wrote:
Irv Kalb <i...@furrypants.com> writes:
about property decorators.
The code
@property
def salary(self): pass
@salary.setter
def salary(self, newSalary): pass
is an abbreviation for
def salary_get(self): pass
salary = property( salary_get )
def salary_set(self, newSalary): pass
salary = salary.setter( salary_set )
. »property« is a class, »property( salaray )« constructs an
instance with salary_get as getter and no setter. Later,
»salary.setter« adds »salaray_set« as a setter to that
instance.
One cannot use »@salary.getter« instead of »@property«,
because at that point in time, the instance »salaray« does
not already exist.
Best answser IMHO, it's clear and concise.
--
Cholo Lennon
Bs.As.
ARG
--
https://mail.python.org/mailman/listinfo/python-list