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
6a6e1e57
Commit
6a6e1e57
authored
Mar 16, 2011
by
Jesus Cea
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
a14b8523
6efb9183
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
Doc/library/collections.rst
Doc/library/collections.rst
+9
-9
No files found.
Doc/library/collections.rst
View file @
6a6e1e57
...
...
@@ -590,7 +590,7 @@ they add the ability to access fields by name instead of position index.
:options: +NORMALIZE_WHITESPACE
>>> # Basic example
>>> Point = namedtuple('Point',
'x y'
)
>>> Point = namedtuple('Point',
['x', 'y']
)
>>> p = Point(x=10, y=11)
>>> # Example using the verbose option to print the class definition
...
...
@@ -735,15 +735,15 @@ functionality with a subclass. Here is how to add a calculated field and
a fixed-width print format:
>>> class Point(namedtuple('Point', 'x y')):
...
__slots__ = ()
...
@property
...
def hypot(self):
...
return (self.x ** 2 + self.y ** 2) ** 0.5
...
def __str__(self):
...
return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
__slots__ = ()
@property
def hypot(self):
return (self.x ** 2 + self.y ** 2) ** 0.5
def __str__(self):
return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
>>> for p in Point(3, 4), Point(14, 5/7):
...
print(p)
print(p)
Point: x= 3.000 y= 4.000 hypot= 5.000
Point: x=14.000 y= 0.714 hypot=14.018
...
...
@@ -770,7 +770,7 @@ and more efficient to use a simple class declaration:
>>> Status.open, Status.pending, Status.closed
(0, 1, 2)
>>> class Status:
...
open, pending, closed = range(3)
open, pending, closed = range(3)
.. seealso::
...
...
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