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
b8b6d3ef
Commit
b8b6d3ef
authored
Feb 06, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let the world know that UserList is a MutableSequence.
parent
8284c4a7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
Lib/UserList.py
Lib/UserList.py
+5
-1
Lib/UserString.py
Lib/UserString.py
+7
-2
No files found.
Lib/UserList.py
View file @
b8b6d3ef
"""A more or less complete user-defined wrapper around list objects."""
class
UserList
:
import
collections
class
UserList
(
collections
.
MutableSequence
):
def
__init__
(
self
,
initlist
=
None
):
self
.
data
=
[]
if
initlist
is
not
None
:
...
...
@@ -69,3 +71,5 @@ class UserList:
self
.
data
.
extend
(
other
.
data
)
else
:
self
.
data
.
extend
(
other
)
collections
.
MutableSequence
.
register
(
UserList
)
Lib/UserString.py
View file @
b8b6d3ef
...
...
@@ -6,10 +6,11 @@ Note: string objects have grown methods in Python 1.6
This module requires Python 1.6 or later.
"""
import
sys
import
collections
__all__
=
[
"UserString"
,
"MutableString"
]
class
UserString
:
class
UserString
(
collections
.
Sequence
)
:
def
__init__
(
self
,
seq
):
if
isinstance
(
seq
,
str
):
self
.
data
=
seq
...
...
@@ -161,7 +162,9 @@ class UserString:
def
upper
(
self
):
return
self
.
__class__
(
self
.
data
.
upper
())
def
zfill
(
self
,
width
):
return
self
.
__class__
(
self
.
data
.
zfill
(
width
))
class
MutableString
(
UserString
):
collections
.
Sequence
.
register
(
UserString
)
class
MutableString
(
UserString
,
collections
.
MutableSequence
):
"""mutable string objects
Python strings are immutable objects. This has the advantage, that
...
...
@@ -230,6 +233,8 @@ class MutableString(UserString):
self
.
data
*=
n
return
self
collections
.
MutableSequence
.
register
(
MutableString
)
if
__name__
==
"__main__"
:
# execute the regression test to stdout, if called as a script:
import
os
...
...
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