MCPcopy Index your code
hub / github.com/python/cpython / split

Function split

Lib/re/__init__.py:243–269  ·  view source on GitHub ↗

Split the source string by the occurrences of the pattern, returning a list containing the resulting substrings. If capturing parentheses are used in pattern, then the text of all groups in the pattern are also returned as part of the resulting list. If maxsplit is nonzero, at most

(pattern, string, *args, maxsplit=_zero_sentinel, flags=_zero_sentinel)

Source from the content-addressed store, hash-verified

241subn.__text_signature__ = '(pattern, repl, string, count=0, flags=0)'
242
243def split(pattern, string, *args, maxsplit=_zero_sentinel, flags=_zero_sentinel):
244 """Split the source string by the occurrences of the pattern,
245 returning a list containing the resulting substrings. If
246 capturing parentheses are used in pattern, then the text of all
247 groups in the pattern are also returned as part of the resulting
248 list. If maxsplit is nonzero, at most maxsplit splits occur,
249 and the remainder of the string is returned as the final element
250 of the list."""
251 if args:
252 if maxsplit is not _zero_sentinel:
253 raise TypeError("split() got multiple values for argument 'maxsplit'")
254 maxsplit, *args = args
255 if args:
256 if flags is not _zero_sentinel:
257 raise TypeError("split() got multiple values for argument 'flags'")
258 flags, *args = args
259 if args:
260 raise TypeError("split() takes from 2 to 4 positional arguments "
261 "but %d were given" % (4 + len(args)))
262
263 import warnings
264 warnings.warn(
265 "'maxsplit' is passed as positional argument",
266 DeprecationWarning, stacklevel=2
267 )
268
269 return _compile(pattern, flags).split(string, maxsplit)
270split.__text_signature__ = '(pattern, string, maxsplit=0, flags=0)'
271
272def findall(pattern, string, flags=0):

Callers 7

_explode_pathFunction · 0.50
suffixesMethod · 0.50
with_nameMethod · 0.50
parentsMethod · 0.50
test_splitMethod · 0.50

Calls 3

_compileFunction · 0.70
warnMethod · 0.45
splitMethod · 0.45

Tested by 3

test_splitMethod · 0.40

Used in the wild real call sites across dependent graphs

searching dependent graphs…