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
857c4c36
Kaydet (Commit)
857c4c36
authored
Şub 10, 2000
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Detabify.
I ran "expand" instead of using Skip's patch, but it's all the same.
üst
8574378a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
string.py
Lib/string.py
+28
-28
No files found.
Lib/string.py
Dosyayı görüntüle @
857c4c36
...
...
@@ -197,10 +197,10 @@ def atof(s):
"""
if
type
(
s
)
==
_StringType
:
return
_float
(
s
)
return
_float
(
s
)
else
:
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
# Convert string to integer
def
atoi
(
*
args
):
...
...
@@ -215,18 +215,18 @@ def atoi(*args):
"""
try
:
s
=
args
[
0
]
s
=
args
[
0
]
except
IndexError
:
raise
TypeError
(
'function requires at least 1 argument:
%
d given'
%
len
(
args
))
raise
TypeError
(
'function requires at least 1 argument:
%
d given'
%
len
(
args
))
# Don't catch type error resulting from too many arguments to int(). The
# error message isn't compatible but the error type is, and this function
# is complicated enough already.
if
type
(
s
)
==
_StringType
:
return
_apply
(
_int
,
args
)
return
_apply
(
_int
,
args
)
else
:
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
# Convert string to long integer
...
...
@@ -243,18 +243,18 @@ def atol(*args):
"""
try
:
s
=
args
[
0
]
s
=
args
[
0
]
except
IndexError
:
raise
TypeError
(
'function requires at least 1 argument:
%
d given'
%
len
(
args
))
raise
TypeError
(
'function requires at least 1 argument:
%
d given'
%
len
(
args
))
# Don't catch type error resulting from too many arguments to long(). The
# error message isn't compatible but the error type is, and this function
# is complicated enough already.
if
type
(
s
)
==
_StringType
:
return
_apply
(
_long
,
args
)
return
_apply
(
_long
,
args
)
else
:
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
raise
TypeError
(
'argument 1: expected string,
%
s found'
%
type
(
s
)
.
__name__
)
# Left-justify a string
...
...
@@ -296,8 +296,8 @@ def center(s, width):
if
n
<=
0
:
return
s
half
=
n
/
2
if
n
%
2
and
width
%
2
:
# This ensures that center(center(s, i), j) = center(s, j)
half
=
half
+
1
# This ensures that center(center(s, i), j) = center(s, j)
half
=
half
+
1
return
' '
*
half
+
s
+
' '
*
(
n
-
half
)
# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'
...
...
@@ -316,7 +316,7 @@ def zfill(x, width):
if
n
>=
width
:
return
s
sign
=
''
if
s
[
0
]
in
(
'-'
,
'+'
):
sign
,
s
=
s
[
0
],
s
[
1
:]
sign
,
s
=
s
[
0
],
s
[
1
:]
return
sign
+
'0'
*
(
width
-
n
)
+
s
# Expand tabs in a string.
...
...
@@ -331,12 +331,12 @@ def expandtabs(s, tabsize=8):
"""
res
=
line
=
''
for
c
in
s
:
if
c
==
'
\t
'
:
c
=
' '
*
(
tabsize
-
len
(
line
)
%
tabsize
)
line
=
line
+
c
if
c
==
'
\n
'
:
res
=
res
+
line
line
=
''
if
c
==
'
\t
'
:
c
=
' '
*
(
tabsize
-
len
(
line
)
%
tabsize
)
line
=
line
+
c
if
c
==
'
\n
'
:
res
=
res
+
line
line
=
''
return
res
+
line
# Character translation through look-up table.
...
...
@@ -385,14 +385,14 @@ def maketrans(fromstr, tostr):
"""
if
len
(
fromstr
)
!=
len
(
tostr
):
raise
ValueError
,
"maketrans arguments must have same length"
raise
ValueError
,
"maketrans arguments must have same length"
global
_idmapL
if
not
_idmapL
:
_idmapL
=
map
(
None
,
_idmap
)
_idmapL
=
map
(
None
,
_idmap
)
L
=
_idmapL
[:]
fromstr
=
map
(
ord
,
fromstr
)
for
i
in
range
(
len
(
fromstr
)):
L
[
fromstr
[
i
]]
=
tostr
[
i
]
L
[
fromstr
[
i
]]
=
tostr
[
i
]
return
joinfields
(
L
,
""
)
# Substring replacement (global)
...
...
@@ -426,4 +426,4 @@ try:
from
strop
import
maketrans
,
lowercase
,
uppercase
,
whitespace
letters
=
lowercase
+
uppercase
except
ImportError
:
pass
# Use the original versions
pass
# Use the original versions
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