diff options
Diffstat (limited to 'Lib/string.py')
-rw-r--r-- | Lib/string.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/string.py b/Lib/string.py index d68b0bf..cd9909e 100644 --- a/Lib/string.py +++ b/Lib/string.py @@ -190,7 +190,10 @@ def rfind(s, *args): _float = float _int = int _long = long -_StringTypes = (str, unicode) +try: + _StringTypes = (str, unicode) +except NameError: + _StringTypes = (str,) # Convert string to float def atof(s): @@ -277,13 +280,8 @@ def zfill(x, width): """ if not isinstance(x, _StringTypes): - x = str(x) - n = len(x) - if n >= width: return x - sign = '' - if x[0] in '-+': - sign, x = x[0], x[1:] - return sign + '0'*(width-n) + x + x = repr(x) + return x.zfill(width) # Expand tabs in a string. # Doesn't take non-printing chars into account, but does understand \n. |