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
418b97ea
Kaydet (Commit)
418b97ea
authored
Haz 12, 2006
tarafından
Neal Norwitz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Cleanup: Remove import of types to get StringTypes, we can just use basestring.
üst
047f3c7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
UserString.py
Lib/UserString.py
+5
-6
No files found.
Lib/UserString.py
Dosyayı görüntüle @
418b97ea
...
@@ -5,14 +5,13 @@
...
@@ -5,14 +5,13 @@
Note: string objects have grown methods in Python 1.6
Note: string objects have grown methods in Python 1.6
This module requires Python 1.6 or later.
This module requires Python 1.6 or later.
"""
"""
from
types
import
StringTypes
import
sys
import
sys
__all__
=
[
"UserString"
,
"MutableString"
]
__all__
=
[
"UserString"
,
"MutableString"
]
class
UserString
:
class
UserString
:
def
__init__
(
self
,
seq
):
def
__init__
(
self
,
seq
):
if
isinstance
(
seq
,
StringTypes
):
if
isinstance
(
seq
,
basestring
):
self
.
data
=
seq
self
.
data
=
seq
elif
isinstance
(
seq
,
UserString
):
elif
isinstance
(
seq
,
UserString
):
self
.
data
=
seq
.
data
[:]
self
.
data
=
seq
.
data
[:]
...
@@ -43,12 +42,12 @@ class UserString:
...
@@ -43,12 +42,12 @@ class UserString:
def
__add__
(
self
,
other
):
def
__add__
(
self
,
other
):
if
isinstance
(
other
,
UserString
):
if
isinstance
(
other
,
UserString
):
return
self
.
__class__
(
self
.
data
+
other
.
data
)
return
self
.
__class__
(
self
.
data
+
other
.
data
)
elif
isinstance
(
other
,
StringTypes
):
elif
isinstance
(
other
,
basestring
):
return
self
.
__class__
(
self
.
data
+
other
)
return
self
.
__class__
(
self
.
data
+
other
)
else
:
else
:
return
self
.
__class__
(
self
.
data
+
str
(
other
))
return
self
.
__class__
(
self
.
data
+
str
(
other
))
def
__radd__
(
self
,
other
):
def
__radd__
(
self
,
other
):
if
isinstance
(
other
,
StringTypes
):
if
isinstance
(
other
,
basestring
):
return
self
.
__class__
(
other
+
self
.
data
)
return
self
.
__class__
(
other
+
self
.
data
)
else
:
else
:
return
self
.
__class__
(
str
(
other
)
+
self
.
data
)
return
self
.
__class__
(
str
(
other
)
+
self
.
data
)
...
@@ -163,7 +162,7 @@ class MutableString(UserString):
...
@@ -163,7 +162,7 @@ class MutableString(UserString):
start
=
max
(
start
,
0
);
end
=
max
(
end
,
0
)
start
=
max
(
start
,
0
);
end
=
max
(
end
,
0
)
if
isinstance
(
sub
,
UserString
):
if
isinstance
(
sub
,
UserString
):
self
.
data
=
self
.
data
[:
start
]
+
sub
.
data
+
self
.
data
[
end
:]
self
.
data
=
self
.
data
[:
start
]
+
sub
.
data
+
self
.
data
[
end
:]
elif
isinstance
(
sub
,
StringTypes
):
elif
isinstance
(
sub
,
basestring
):
self
.
data
=
self
.
data
[:
start
]
+
sub
+
self
.
data
[
end
:]
self
.
data
=
self
.
data
[:
start
]
+
sub
+
self
.
data
[
end
:]
else
:
else
:
self
.
data
=
self
.
data
[:
start
]
+
str
(
sub
)
+
self
.
data
[
end
:]
self
.
data
=
self
.
data
[:
start
]
+
str
(
sub
)
+
self
.
data
[
end
:]
...
@@ -175,7 +174,7 @@ class MutableString(UserString):
...
@@ -175,7 +174,7 @@ class MutableString(UserString):
def
__iadd__
(
self
,
other
):
def
__iadd__
(
self
,
other
):
if
isinstance
(
other
,
UserString
):
if
isinstance
(
other
,
UserString
):
self
.
data
+=
other
.
data
self
.
data
+=
other
.
data
elif
isinstance
(
other
,
StringTypes
):
elif
isinstance
(
other
,
basestring
):
self
.
data
+=
other
self
.
data
+=
other
else
:
else
:
self
.
data
+=
str
(
other
)
self
.
data
+=
str
(
other
)
...
...
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