Skip to content

Commit

Permalink
feat: str.split(None[, maxsplit])
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed May 8, 2024
1 parent 384fca3 commit c7059c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/pylib/pystring/split/reimporter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import ../errHandle
import ../consts
import ../../builtins/list
import ../../noneType


export errHandle, list, consts
export errHandle, list, consts, noneType

4 changes: 2 additions & 2 deletions src/pylib/pystring/split/split.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ./reimporter
import ./split_whitespace


iterator split*(a: PyStr, maxsplit = -1): PyStr =
iterator split*(a: PyStr, sep = None, maxsplit = -1): PyStr =
## with unicode whitespaces as sep.
##
## treat runs of whitespaces as one sep (i.e.
Expand All @@ -28,7 +28,7 @@ iterator split*(a: StringLike,
noEmptySep sep
for i in splitNoCheck($a, sep, maxsplit): yield i

proc split*(a: StringLike, maxsplit = -1): PyList[PyStr] =
proc split*(a: StringLike, sep = None, maxsplit = -1): PyList[PyStr] =
str(a).split_whitespace(maxsplit)

# strutils.split func does not use any predicted capacity.
Expand Down

0 comments on commit c7059c2

Please sign in to comment.