[Tutor] Class access rules
Phil
phillor9 at gmail.com
Sun Mar 6 22:54:58 EST 2022
On 7/3/22 12:31, Cameron Simpson wrote:
> We don't do much setter/getter methods in Python. We do something make
> properties, which present as attributes to the outside and are
> implemented as getter methods with optional setter methods. Example:
>
> @property
> def post_pos(self):
> ''' The location "beyond" the rectangle implied by pos+size.
> '''
> return (self.pos[0] + self.size, self.pos[1] + self.size)
Thanks Cameron, I read a brief explanation about the use the @property
decorator but couldn't see where I could use it. I'll continue with my
current line of class usage.
--
Regards,
Phil
More information about the Tutor
mailing list