Skip to content

Instantly share code, notes, and snippets.

@hainm
Created April 8, 2015 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hainm/c7bfcbe504b1dc6bd3cf to your computer and use it in GitHub Desktop.
Save hainm/c7bfcbe504b1dc6bd3cf to your computer and use it in GitHub Desktop.
cython settter
cdef class MyTest (object):
cdef public object _x
def __cinit__(self):
self._x = 0
@property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = value
# property x:
# def __get__(self):
# return self._x
# def __set__(self, value):
# self._x = value
t = MyTest()
print (t.x)
t.x = 100.
print (t.x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment