Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
575ee4c4
Commit
575ee4c4
authored
Aug 10, 2014
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #22174: Clean-up grammar and ambiguities in property() docs.
parent
baa84b82
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
Doc/library/functions.rst
Doc/library/functions.rst
+13
-7
Misc/ACKS
Misc/ACKS
+1
-0
No files found.
Doc/library/functions.rst
View file @
575ee4c4
...
...
@@ -992,9 +992,11 @@ available. They are listed here in alphabetical order.
Return a property attribute for :term:`new-style class`\es (classes that
derive from :class:`object`).
*fget* is a function for getting an attribute value, likewise *fset* is a
function for setting, and *fdel* a function for del'ing, an attribute. Typical
use is to define a managed attribute ``x``::
*fget* is a function for getting an attribute value. *fset* is a function
for setting an attribute value. *fdel* is a function for deleting an attribute
value. And *doc* creates a docstring for the attribute.
A typical use is to define a managed attribute ``x``::
class C(object):
def __init__(self):
...
...
@@ -1002,13 +1004,16 @@ available. They are listed here in alphabetical order.
def getx(self):
return self._x
def setx(self, value):
self._x = value
def delx(self):
del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
If
then
*c* is an instance of *C*, ``c.x`` will invoke the getter,
If *c* is an instance of *C*, ``c.x`` will invoke the getter,
``c.x = value`` will invoke the setter and ``del c.x`` the deleter.
If given, *doc* will be the docstring of the property attribute. Otherwise, the
...
...
@@ -1024,8 +1029,9 @@ available. They are listed here in alphabetical order.
"""Get the current voltage."""
return self._voltage
turns the :meth:`voltage` method into a "getter" for a read-only attribute
with the same name.
The ``@property`` decorator turns the :meth:`voltage` method into a "getter"
for a read-only attribute with the same name, and it sets the docstring for
*voltage* to "Get the current voltage."
A property object has :attr:`~property.getter`, :attr:`~property.setter`,
and :attr:`~property.deleter` methods usable as decorators that create a
...
...
@@ -1053,7 +1059,7 @@ available. They are listed here in alphabetical order.
additional functions the same name as the original property (``x`` in this
case.)
The returned property also has the attributes ``fget``, ``fset``, and
The returned property
object
also has the attributes ``fget``, ``fset``, and
``fdel`` corresponding to the constructor arguments.
.. versionadded:: 2.2
...
...
Misc/ACKS
View file @
575ee4c4
...
...
@@ -245,6 +245,7 @@ David Cinege
Craig Citro
Gilles Civario
Chris Clark
Diana Clarke
Laurie Clark-Michalek
Mike Clarkson
Andrew Clegg
...
...
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