Mercurial > cpython-lru_cache-weakref
diff Lib/string.py @ 928:8725fa8d7ff9 legacy-trunk
Removed *.libs (now in ./sgi);
added gettext() method to TextEdit.py;
fixed string.atoi() to ignore leading zeros.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 06 Aug 1992 22:33:41 +0000 |
| parents | 476bb7e5b854 |
| children | ffe2fbc583de |
line wrap: on
line diff
--- a/Lib/string.py Thu Aug 06 16:53:58 1992 +0000 +++ b/Lib/string.py Thu Aug 06 22:33:41 1992 +0000 @@ -102,12 +102,16 @@ # 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):
