Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/python-wasm
Path: blob/main/python/pylang/src/lib/pythonize.py
1398 views
1
# vim:fileencoding=utf-8
2
# License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
# globals: ρσ_str
4
5
6
def strings():
7
string_funcs = set((
8
'capitalize strip lstrip rstrip islower isupper isspace lower upper swapcase'
9
' center count endswith startswith find rfind index rindex format join ljust rjust'
10
' partition rpartition replace split rsplit splitlines zfill'
11
).split(' '))
12
13
if not arguments.length:
14
exclude = {'split', 'replace'}
15
elif arguments[0]:
16
exclude = Array.prototype.slice.call(arguments)
17
else:
18
exclude = None
19
if exclude:
20
string_funcs = string_funcs.difference(set(exclude))
21
for name in string_funcs:
22
String.prototype[name] = ρσ_str.prototype[name]
23
24