diff Lib/stringold.py @ 6519:24da035ceb6e legacy-trunk

Convert all remaining *simple* cases of regex usage to re usage.
author Guido van Rossum <guido@python.org>
date Wed, 22 Oct 1997 21:00:49 +0000
parents 071a0d3a49b9
children d790fe25e148
line wrap: on
line diff
--- a/Lib/stringold.py	Wed Oct 22 20:56:32 1997 +0000
+++ b/Lib/stringold.py	Wed Oct 22 21:00:49 1997 +0000
@@ -193,17 +193,20 @@
 	return r
 
 # Convert string to float
+re = None
 def atof(str):
-	import regex
+	global re
+	if re is None:
+		import re
 	sign = ''
-	s = str
+	s = strip(str)
 	if s and s[0] in '+-':
 		sign = s[0]
 		s = s[1:]
 	if not s:
 		raise ValueError, 'non-float argument to string.atof'
 	while s[0] == '0' and len(s) > 1 and s[1] in digits: s = s[1:]
-	if regex.match('[0-9]*\(\.[0-9]*\)?\([eE][-+]?[0-9]+\)?', s) != len(s):
+	if not re.match('[0-9]*(\.[0-9]*)?([eE][-+]?[0-9]+)?$', s):
 		raise ValueError, 'non-float argument to string.atof'
 	try:
 		return float(eval(sign + s))