Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cython
Commits
25de842f
Commit
25de842f
authored
Apr 05, 2016
by
Björn Dahlgren
Committed by
Stefan Behnel
Jul 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update docs wrt property syntax deprecation
parent
f5c02d3d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
16 deletions
+37
-16
docs/src/reference/extension_types.rst
docs/src/reference/extension_types.rst
+2
-2
docs/src/tutorial/cdef_classes.rst
docs/src/tutorial/cdef_classes.rst
+6
-5
docs/src/userguide/extension_types.rst
docs/src/userguide/extension_types.rst
+29
-9
No files found.
docs/src/reference/extension_types.rst
View file @
25de842f
...
...
@@ -81,7 +81,7 @@ Methods
Properties
==========
* Cython provides a special syntax::
* Cython provides a special
(deprecated)
syntax::
cdef class Spam:
...
...
@@ -120,7 +120,7 @@ Properties
def __cinit__(self):
self.cheeses = []
property cheese:
property cheese:
# note that this syntax is deprecated
def __get__(self):
return "We don't have: %s" % self.cheeses
...
...
docs/src/tutorial/cdef_classes.rst
View file @
25de842f
...
...
@@ -138,9 +138,10 @@ Attributes in cdef classes behave differently from attributes in regular classes
# Available in Python-space:
cdef public double freq
# Available in Python-space:
property period:
def __get__
(self):
@property
def period
(self):
return 1.0 / self.freq
def __set__(self, value):
@period.setter
def period(self, value):
self.freq = 1.0 / value
<...>
docs/src/userguide/extension_types.rst
View file @
25de842f
...
...
@@ -223,7 +223,26 @@ extension types.
Properties
============
There is a special syntax for defining properties in an extension class::
You can declare properties in an extension class using the same syntax as in ordinary Python code::
cdef class Spam:
@property
def cheese(self):
# This is called when the property is read.
...
@cheese.setter
def cheese(self, value):
# This is called when the property is written.
...
@cheese.deleter
def cheese(self):
# This is called when the property is deleted.
There is also a special (deprecated) legacy syntax for defining properties in an extension class::
cdef class Spam:
...
...
@@ -259,15 +278,16 @@ when it is deleted.::
def __cinit__(self):
self.cheeses = []
property cheese:
def __get__(self):
@property
def cheese(self):
return "We don't have: %s" % self.cheeses
def __set__(self, value):
@cheese.setter
def cheese(self):
self.cheeses.append(value)
def __del__(self):
@cheese.deleter
def cheese(self):
del self.cheeses[:]
# Test input
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment