[Tutor] Get/Set/Attribute Accessors in Python?

eryksun eryksun at gmail.com
Thu Dec 6 07:21:03 CET 2012


On Wed, Dec 5, 2012 at 10:38 AM, Malcolm Newsome
<malcolm.newsome at gmail.com> wrote:
>
> One thing I've come across in C# (and, quite frankly, am having a difficult
> time grasping) is Get and Set (Accessors).
>
> Since, I don't ever recall reading about this in Python, I'm wondering if
> they exist.

Python uses what it calls "descriptors" to create bound methods and
handle special properties such as __dict__, __weakref__, and slots
defined by __slots__. You can roll  your own as you see fit. Raymond
Hettinger's guide is a good place to start:

http://docs.python.org/3/howto/descriptor.html


More information about the Tutor mailing list