Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f2072771
Kaydet (Commit)
f2072771
authored
May 20, 2002
tarafından
Michael W. Hudson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More --disable-unicode stuff.
I'm getting better at vi!
üst
3704644a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
UserString.py
Lib/UserString.py
+6
-6
string_tests.py
Lib/test/string_tests.py
+9
-4
No files found.
Lib/UserString.py
Dosyayı görüntüle @
f2072771
...
...
@@ -5,14 +5,14 @@
Note: string objects have grown methods in Python 1.6
This module requires Python 1.6 or later.
"""
from
types
import
StringType
,
UnicodeType
from
types
import
StringType
s
import
sys
__all__
=
[
"UserString"
,
"MutableString"
]
class
UserString
:
def
__init__
(
self
,
seq
):
if
isinstance
(
seq
,
StringType
)
or
isinstance
(
seq
,
UnicodeType
):
if
isinstance
(
seq
,
StringType
s
):
self
.
data
=
seq
elif
isinstance
(
seq
,
UserString
):
self
.
data
=
seq
.
data
[:]
...
...
@@ -43,19 +43,19 @@ class UserString:
def
__add__
(
self
,
other
):
if
isinstance
(
other
,
UserString
):
return
self
.
__class__
(
self
.
data
+
other
.
data
)
elif
isinstance
(
other
,
StringType
)
or
isinstance
(
other
,
UnicodeType
):
elif
isinstance
(
other
,
StringType
s
):
return
self
.
__class__
(
self
.
data
+
other
)
else
:
return
self
.
__class__
(
self
.
data
+
str
(
other
))
def
__radd__
(
self
,
other
):
if
isinstance
(
other
,
StringType
)
or
isinstance
(
other
,
UnicodeType
):
if
isinstance
(
other
,
StringType
s
):
return
self
.
__class__
(
other
+
self
.
data
)
else
:
return
self
.
__class__
(
str
(
other
)
+
self
.
data
)
def
__iadd__
(
self
,
other
):
if
isinstance
(
other
,
UserString
):
self
.
data
+=
other
.
data
elif
isinstance
(
other
,
StringType
)
or
isinstance
(
other
,
UnicodeType
):
elif
isinstance
(
other
,
StringType
s
):
self
.
data
+=
other
else
:
self
.
data
+=
str
(
other
)
...
...
@@ -159,7 +159,7 @@ class MutableString(UserString):
start
=
max
(
start
,
0
);
end
=
max
(
end
,
0
)
if
isinstance
(
sub
,
UserString
):
self
.
data
=
self
.
data
[:
start
]
+
sub
.
data
+
self
.
data
[
end
:]
elif
isinstance
(
sub
,
StringType
)
or
isinstance
(
sub
,
UnicodeType
):
elif
isinstance
(
sub
,
StringType
s
):
self
.
data
=
self
.
data
[:
start
]
+
sub
+
self
.
data
[
end
:]
else
:
self
.
data
=
self
.
data
[:
start
]
+
str
(
sub
)
+
self
.
data
[
end
:]
...
...
Lib/test/string_tests.py
Dosyayı görüntüle @
f2072771
...
...
@@ -176,10 +176,15 @@ def run_method_tests(test):
test
(
'strip'
,
'hello'
,
'hello'
,
'xyz'
)
# strip/lstrip/rstrip with unicode arg
test
(
'strip'
,
'xyzzyhelloxyzzy'
,
u'hello'
,
u'xyz'
)
test
(
'lstrip'
,
'xyzzyhelloxyzzy'
,
u'helloxyzzy'
,
u'xyz'
)
test
(
'rstrip'
,
'xyzzyhelloxyzzy'
,
u'xyzzyhello'
,
u'xyz'
)
test
(
'strip'
,
'hello'
,
u'hello'
,
u'xyz'
)
if
have_unicode
:
test
(
'strip'
,
'xyzzyhelloxyzzy'
,
unicode
(
'hello'
,
'ascii'
),
unicode
(
'xyz'
,
'ascii'
))
test
(
'lstrip'
,
'xyzzyhelloxyzzy'
,
unicode
(
'helloxyzzy'
,
'ascii'
),
unicode
(
'xyz'
,
'ascii'
))
test
(
'rstrip'
,
'xyzzyhelloxyzzy'
,
unicode
(
'xyzzyhello'
,
'ascii'
),
unicode
(
'xyz'
,
'ascii'
))
test
(
'strip'
,
'hello'
,
unicode
(
'hello'
,
'ascii'
),
unicode
(
'xyz'
,
'ascii'
))
test
(
'swapcase'
,
'HeLLo cOmpUteRs'
,
'hEllO CoMPuTErS'
)
test
(
'translate'
,
'xyzabcdef'
,
'xyzxyz'
,
transtable
,
'def'
)
...
...
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