summaryrefslogtreecommitdiffstats
path: root/Lib/stringold.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
committerGuido van Rossum <guido@python.org>1997-10-22 21:00:49 (GMT)
commit9694fcab5332f27dc28b195ba1391e5491d2eaef (patch)
tree23dc3d9a7d1cc4b138ac2bffd028a519cba93b30 /Lib/stringold.py
parent426916e50e1209d8ecc12678855dc531863a48c5 (diff)
downloadcpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.zip
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.gz
cpython-9694fcab5332f27dc28b195ba1391e5491d2eaef.tar.bz2
Convert all remaining *simple* cases of regex usage to re usage.
Diffstat (limited to 'Lib/stringold.py')
-rw-r--r--Lib/stringold.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/Lib/stringold.py b/Lib/stringold.py
index 5cf5b6f..3f65978 100644
--- a/Lib/stringold.py
+++ b/Lib/stringold.py
@@ -193,17 +193,20 @@ def rfind(s, sub, i = 0, last=None):
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))