MCPcopy Index your code
hub / github.com/RustPython/RustPython / split

Function split

Lib/re/__init__.py:241–267  ·  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

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

Callers 6

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

Calls 4

lenFunction · 0.85
_compileFunction · 0.70
warnMethod · 0.45
splitMethod · 0.45

Tested by 2