Abstracting away the type of a property
Posted
by
L. De Leo
on Programmers
See other posts from Programmers
or by L. De Leo
Published on 2012-08-09T13:22:39Z
Indexed on
2012/08/29
21:51 UTC
Read the original article
Hit count: 577
In Python luckily most of the times you don't have to write getters and setters to get access to class properties. That said sometimes you'll have to remember that a certain property is a list or whatnot and a property would save you there by abstracting the type and providing a setter to add something to such list for example rather than exposing the list directly.
Where do you draw the line between exposing the type directly or wrapping its access in a property? What's the general "pythonic" advice?
© Programmers or respective owner