mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Removed *.libs (now in ./sgi);
added gettext() method to TextEdit.py; fixed string.atoi() to ignore leading zeros.
This commit is contained in:
parent
de126a6ff8
commit
2d4aa4f5d4
4 changed files with 18 additions and 4 deletions
|
@ -27,6 +27,9 @@ class TextEdit:
|
||||||
def settext(self, text):
|
def settext(self, text):
|
||||||
self.editor.settext(text)
|
self.editor.settext(text)
|
||||||
#
|
#
|
||||||
|
def gettext(self):
|
||||||
|
return self.editor.gettext(text)
|
||||||
|
#
|
||||||
# Downcalls from parent to child
|
# Downcalls from parent to child
|
||||||
#
|
#
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
|
|
@ -27,6 +27,9 @@ class TextEdit:
|
||||||
def settext(self, text):
|
def settext(self, text):
|
||||||
self.editor.settext(text)
|
self.editor.settext(text)
|
||||||
#
|
#
|
||||||
|
def gettext(self):
|
||||||
|
return self.editor.gettext(text)
|
||||||
|
#
|
||||||
# Downcalls from parent to child
|
# Downcalls from parent to child
|
||||||
#
|
#
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
|
|
@ -102,12 +102,16 @@ def index(s, sub):
|
||||||
# Convert string to integer
|
# Convert string to integer
|
||||||
atoi_error = 'non-numeric argument to string.atoi'
|
atoi_error = 'non-numeric argument to string.atoi'
|
||||||
def atoi(str):
|
def atoi(str):
|
||||||
|
sign = ''
|
||||||
s = str
|
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
|
if not s: raise atoi_error, str
|
||||||
|
while s[0] == '0' and len(s) > 1: s = s[1:]
|
||||||
for c in s:
|
for c in s:
|
||||||
if c not in digits: raise atoi_error, str
|
if c not in digits: raise atoi_error, str
|
||||||
return eval(str)
|
return eval(sign + s)
|
||||||
|
|
||||||
# Left-justify a string
|
# Left-justify a string
|
||||||
def ljust(s, width):
|
def ljust(s, width):
|
||||||
|
|
|
@ -102,12 +102,16 @@ def index(s, sub):
|
||||||
# Convert string to integer
|
# Convert string to integer
|
||||||
atoi_error = 'non-numeric argument to string.atoi'
|
atoi_error = 'non-numeric argument to string.atoi'
|
||||||
def atoi(str):
|
def atoi(str):
|
||||||
|
sign = ''
|
||||||
s = str
|
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
|
if not s: raise atoi_error, str
|
||||||
|
while s[0] == '0' and len(s) > 1: s = s[1:]
|
||||||
for c in s:
|
for c in s:
|
||||||
if c not in digits: raise atoi_error, str
|
if c not in digits: raise atoi_error, str
|
||||||
return eval(str)
|
return eval(sign + s)
|
||||||
|
|
||||||
# Left-justify a string
|
# Left-justify a string
|
||||||
def ljust(s, width):
|
def ljust(s, width):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue