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
c1b6a4a1
Commit
c1b6a4a1
authored
Feb 08, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Smalls improvement to example in the docs for collections ABCs.
parent
8eed4492
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Doc/library/collections.rst
Doc/library/collections.rst
+7
-5
No files found.
Doc/library/collections.rst
View file @
c1b6a4a1
...
...
@@ -43,10 +43,8 @@ ABC Notes
:class:`Iterable`,
and :class:`Sized`, and in addition
defines ``__getitem__()``, ``get()``,
``__contains__()``, ``__len__()``,
``__eq__()``, ``__ne__()``,
``__iter__()``, ``keys()``,
``items()``, and ``values()``
``keys()``, ``items()``, and ``values()``
:class:`collections.MutableMapping` Derived from :class:`Mapping`
:class:`collections.Sequence` Derived from :class:`Container`,
:class:`Iterable`, and :class:`Sized`,
...
...
@@ -83,9 +81,13 @@ The ABC supplies the remaining methods such as :meth:`__and__` and
:meth:`isdisjoint` ::
class ListBasedSet(collections.Set):
'Alternate set implementation favoring space over speed'
''' Alternate set implementation favoring space over speed
and not requiring the set elements to be hashable. '''
def __init__(self, iterable):
self.elements = list(set(iterable))
self.elements = lst = []
for value in iterable:
if value not in lst:
lst.append(value)
def __iter__(self):
return iter(self.elements)
def __contains__(self, value):
...
...
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