summaryrefslogtreecommitdiffstats
path: root/Lib/stringold.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-11-05 10:43:02 (GMT)
committerGuido van Rossum <guido@python.org>1992-11-05 10:43:02 (GMT)
commitc629d34c4f1797b690a6c93ea3e2a5b82698b686 (patch)
tree812dcbc9fd664f9a5354e3301d7aa2375d85517a /Lib/stringold.py
parent1115ab2a7469746859655cfa7f717c794a8a22ab (diff)
downloadcpython-c629d34c4f1797b690a6c93ea3e2a5b82698b686.zip
cpython-c629d34c4f1797b690a6c93ea3e2a5b82698b686.tar.gz
cpython-c629d34c4f1797b690a6c93ea3e2a5b82698b686.tar.bz2
* change default line numbers for 'list' in pdb.py
* changed eval() into getattr() in cmd.py * added dirname(), basename() and (dummy) normath() to macpath.py * renamed nntp.py to nntplib.py * Made string.index() compatible with strop.index() * Make string.atoi('') raise string.atoi_error rather than ValueError * Added dirname() and normpath() to posixpath.
Diffstat (limited to 'Lib/stringold.py')
-rw-r--r--Lib/stringold.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/Lib/stringold.py b/Lib/stringold.py
index cc60678..b4e0d5e 100644
--- a/Lib/stringold.py
+++ b/Lib/stringold.py
@@ -96,10 +96,18 @@ def joinfields(words, sep):
# Find substring
index_error = 'substring not found in string.index'
-def index(s, sub):
+def index(s, sub, *args):
+ if args:
+ if len(args) > 1:
+ raise TypeError, 'string.index(): too many args'
+ i = args[0]
+ else:
+ i = 0
n = len(sub)
- for i in range(len(s) + 1 - n):
+ m = len(s) + 1 - n
+ while i < m:
if sub == s[i:i+n]: return i
+ i = i+1
raise index_error, (s, sub)
# Convert string to integer
@@ -107,7 +115,7 @@ atoi_error = 'non-numeric argument to string.atoi'
def atoi(str):
sign = ''
s = str
- if s[:1] in '+-':
+ if s and s[0] in '+-':
sign = s[0]
s = s[1:]
if not s: raise atoi_error, str