mirror of
https://github.com/python/cpython.git
synced 2025-08-28 20:56:54 +00:00
New module regsub contains sub(), gsub() and split() as in nawk.
string.splitfields(s, '') now returns [s] as split() in nawk. Added _exit to exported functions of os.
This commit is contained in:
parent
7066dd75c5
commit
7a461e5aaf
4 changed files with 152 additions and 6 deletions
|
@ -63,13 +63,12 @@ def split(s):
|
|||
|
||||
# Split a list into fields separated by a given string
|
||||
# NB: splitfields(s, ' ') is NOT the same as split(s)!
|
||||
# splitfields(s, '') is illegal
|
||||
splitfields_error = 'string.splitfields called with empty separator'
|
||||
# splitfields(s, '') returns [s] (in analogy with split() in nawk)
|
||||
def splitfields(s, sep):
|
||||
res = []
|
||||
nsep = len(sep)
|
||||
if nsep == 0:
|
||||
raise splitfields_error
|
||||
return [s]
|
||||
ns = len(s)
|
||||
i = j = 0
|
||||
while j+nsep <= ns:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue