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
2ab19920
Kaydet (Commit)
2ab19920
authored
Haz 22, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
make split and splitfields, join and joinfields synonyms
üst
efe5ac40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
string.py
Lib/string.py
+8
-6
stringold.py
Lib/stringold.py
+8
-6
No files found.
Lib/string.py
Dosyayı görüntüle @
2ab19920
...
@@ -57,7 +57,8 @@ def strip(s):
...
@@ -57,7 +57,8 @@ def strip(s):
# Split a string into a list of space/tab-separated words
# Split a string into a list of space/tab-separated words
# NB: split(s) is NOT the same as splitfields(s, ' ')!
# NB: split(s) is NOT the same as splitfields(s, ' ')!
def
split
(
s
):
def
split
(
s
,
sep
=
None
):
if
sep
is
not
None
:
return
splitfields
(
s
,
sep
)
res
=
[]
res
=
[]
i
,
n
=
0
,
len
(
s
)
i
,
n
=
0
,
len
(
s
)
while
i
<
n
:
while
i
<
n
:
...
@@ -72,7 +73,8 @@ def split(s):
...
@@ -72,7 +73,8 @@ def split(s):
# Split a list into fields separated by a given string
# Split a list into fields separated by a given string
# NB: splitfields(s, ' ') is NOT the same as split(s)!
# NB: splitfields(s, ' ') is NOT the same as split(s)!
# splitfields(s, '') returns [s] (in analogy with split() in nawk)
# splitfields(s, '') returns [s] (in analogy with split() in nawk)
def
splitfields
(
s
,
sep
):
def
splitfields
(
s
,
sep
=
None
):
if
sep
is
None
:
return
split
(
s
)
res
=
[]
res
=
[]
nsep
=
len
(
sep
)
nsep
=
len
(
sep
)
if
nsep
==
0
:
if
nsep
==
0
:
...
@@ -89,11 +91,11 @@ def splitfields(s, sep):
...
@@ -89,11 +91,11 @@ def splitfields(s, sep):
return
res
return
res
# Join words with spaces between them
# Join words with spaces between them
def
join
(
words
):
def
join
(
words
,
sep
=
' '
):
return
joinfields
(
words
,
' '
)
return
joinfields
(
words
,
sep
)
# Join fields with separator
# Join fields with
optional
separator
def
joinfields
(
words
,
sep
):
def
joinfields
(
words
,
sep
=
' '
):
res
=
''
res
=
''
for
w
in
words
:
for
w
in
words
:
res
=
res
+
(
sep
+
w
)
res
=
res
+
(
sep
+
w
)
...
...
Lib/stringold.py
Dosyayı görüntüle @
2ab19920
...
@@ -57,7 +57,8 @@ def strip(s):
...
@@ -57,7 +57,8 @@ def strip(s):
# Split a string into a list of space/tab-separated words
# Split a string into a list of space/tab-separated words
# NB: split(s) is NOT the same as splitfields(s, ' ')!
# NB: split(s) is NOT the same as splitfields(s, ' ')!
def
split
(
s
):
def
split
(
s
,
sep
=
None
):
if
sep
is
not
None
:
return
splitfields
(
s
,
sep
)
res
=
[]
res
=
[]
i
,
n
=
0
,
len
(
s
)
i
,
n
=
0
,
len
(
s
)
while
i
<
n
:
while
i
<
n
:
...
@@ -72,7 +73,8 @@ def split(s):
...
@@ -72,7 +73,8 @@ def split(s):
# Split a list into fields separated by a given string
# Split a list into fields separated by a given string
# NB: splitfields(s, ' ') is NOT the same as split(s)!
# NB: splitfields(s, ' ') is NOT the same as split(s)!
# splitfields(s, '') returns [s] (in analogy with split() in nawk)
# splitfields(s, '') returns [s] (in analogy with split() in nawk)
def
splitfields
(
s
,
sep
):
def
splitfields
(
s
,
sep
=
None
):
if
sep
is
None
:
return
split
(
s
)
res
=
[]
res
=
[]
nsep
=
len
(
sep
)
nsep
=
len
(
sep
)
if
nsep
==
0
:
if
nsep
==
0
:
...
@@ -89,11 +91,11 @@ def splitfields(s, sep):
...
@@ -89,11 +91,11 @@ def splitfields(s, sep):
return
res
return
res
# Join words with spaces between them
# Join words with spaces between them
def
join
(
words
):
def
join
(
words
,
sep
=
' '
):
return
joinfields
(
words
,
' '
)
return
joinfields
(
words
,
sep
)
# Join fields with separator
# Join fields with
optional
separator
def
joinfields
(
words
,
sep
):
def
joinfields
(
words
,
sep
=
' '
):
res
=
''
res
=
''
for
w
in
words
:
for
w
in
words
:
res
=
res
+
(
sep
+
w
)
res
=
res
+
(
sep
+
w
)
...
...
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