diff Lib/stringold.py @ 1052:6508ea32c6b0 legacy-trunk

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.
author Guido van Rossum <guido@python.org>
date Sun, 20 Sep 1992 21:41:09 +0000
parents ffe2fbc583de
children 245003c006a6
line wrap: on
line diff
--- a/Lib/stringold.py	Thu Sep 17 17:54:56 1992 +0000
+++ b/Lib/stringold.py	Sun Sep 20 21:41:09 1992 +0000
@@ -63,13 +63,12 @@
 
 # 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: