From 2d4aa4f5d43842bc049752ab8d5ffa3d2880cbe6 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 6 Aug 1992 22:33:41 +0000 Subject: Removed *.libs (now in ./sgi); added gettext() method to TextEdit.py; fixed string.atoi() to ignore leading zeros. --- Lib/stringold.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Lib/stringold.py') diff --git a/Lib/stringold.py b/Lib/stringold.py index cfb977fcc3..94e91570c5 100644 --- a/Lib/stringold.py +++ b/Lib/stringold.py @@ -102,12 +102,16 @@ def index(s, sub): # Convert string to integer atoi_error = 'non-numeric argument to string.atoi' def atoi(str): + sign = '' s = str - if s[:1] in '+-': s = s[1:] + if s[:1] in '+-': + sign = s[0] + s = s[1:] if not s: raise atoi_error, str + while s[0] == '0' and len(s) > 1: s = s[1:] for c in s: if c not in digits: raise atoi_error, str - return eval(str) + return eval(sign + s) # Left-justify a string def ljust(s, width): -- cgit v1.2.1