FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
mip/python-stdlib/string/string.py at PyDevices · PyDevices/mip · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
PyDevices
/
mip
Public
forked from
micropython/micropython-lib
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
mip
/
python-stdlib
/
string
/
string.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
27 lines (24 loc) · 761 Bytes
Breadcrumbs
mip
/
python-stdlib
/
string
/
string.py
Copy path
File metadata and controls
27 lines (24 loc) · 761 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Some strings for ctype-style character classification
whitespace
=
"
\t
\n
\r
\v
\f
"
ascii_lowercase
=
"abcdefghijklmnopqrstuvwxyz"
ascii_uppercase
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ascii_letters
=
ascii_lowercase
+
ascii_uppercase
digits
=
"0123456789"
hexdigits
=
digits
+
"abcdef"
+
"ABCDEF"
octdigits
=
"01234567"
punctuation
=
"""!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
printable
=
digits
+
ascii_letters
+
punctuation
+
whitespace
def
translate
(
s
,
map
):
import
io
sb
=
io
.
StringIO
()
for
c
in
s
:
v
=
ord
(
c
)
if
v
in
map
:
v
=
map
[
v
]
if
isinstance
(
v
,
int
):
sb
.
write
(
chr
(
v
))
elif
v
is
not
None
:
sb
.
write
(
v
)
else
:
sb
.
write
(
c
)
return
sb
.
getvalue
()
Back
|
FazBrowse Home
|
New Git URL