Skip to content

Instantly share code, notes, and snippets.

@is55555
is55555 / descriptorExample.py
Last active February 20, 2017 11:18
basic example outlining how to use descriptors
# ***** "raw" descriptor not using "property" or property decorators.
class Descriptor(object): # simply encapsulates the management of the attribute "_name"
def __init__(self):
self._name = ''
def __get__(self, instance, owner):
print "Getting: %s" % self._name
return self._name
def __set__(self, instance, name):