1.1 --- a/lib/__builtins__/str.py Wed Nov 30 18:44:58 2016 +0100
1.2 +++ b/lib/__builtins__/str.py Thu Dec 01 17:17:10 2016 +0100
1.3 @@ -19,26 +19,27 @@
1.4 this program. If not, see <http://www.gnu.org/licenses/>.
1.5 """
1.6
1.7 -from __builtins__.identity import isclass
1.8 -from __builtins__.iterator import listiterator
1.9 from __builtins__.operator import _binary_op, _negate
1.10 import native
1.11
1.12 -class basestring(object):
1.13 - def __init__(self, data=None):
1.14 - # Note member.
1.15 - self.__data__ = ""
1.16 +class basestring:
1.17 +
1.18 + "The base class for all strings."
1.19 +
1.20 + def __init__(self):
1.21
1.22 - def __contains__(self, value): pass
1.23 + "Initialise the string."
1.24
1.25 - def __getitem__(self, index):
1.26 - # Note usage.
1.27 - IndexError
1.28 + # Note the __data__ member. Since strings are either initialised from
1.29 + # literals or converted using routines defined for other types, no form
1.30 + # of actual initialisation is performed here.
1.31
1.32 - def __getslice__(self, start, end=None): pass
1.33 + self.__data__ = None
1.34
1.35 def __iadd__(self, other):
1.36 +
1.37 "Return a new string for the operation."
1.38 +
1.39 return _binary_op(self, other, native._str_add)
1.40
1.41 __add__ = __radd__ = __iadd__
1.42 @@ -49,38 +50,54 @@
1.43 def __rmod__(self, other): pass
1.44
1.45 def __lt__(self, other):
1.46 +
1.47 "Return a new boolean for the comparison."
1.48 +
1.49 return _binary_op(self, other, native._str_lt)
1.50
1.51 def __gt__(self, other):
1.52 +
1.53 "Return a new boolean for the comparison."
1.54 +
1.55 return _binary_op(self, other, native._str_gt)
1.56
1.57 def __le__(self, other):
1.58 +
1.59 "Return a new boolean for the comparison."
1.60 +
1.61 return _negate(self.__gt__(other))
1.62
1.63 def __ge__(self, other):
1.64 +
1.65 "Return a new boolean for the comparison."
1.66 +
1.67 return _negate(self.__lt__(other))
1.68
1.69 def __eq__(self, other):
1.70 +
1.71 "Return a new boolean for the comparison."
1.72 +
1.73 return _binary_op(self, other, native._str_eq)
1.74
1.75 def __ne__(self, other):
1.76 +
1.77 "Return a new boolean for the comparison."
1.78 +
1.79 return _negate(self.__eq__(other))
1.80
1.81 def __len__(self):
1.82 return native._str_len(self)
1.83
1.84 def __str__(self):
1.85 +
1.86 "Return a string representation."
1.87 +
1.88 return self
1.89
1.90 def __repr__(self):
1.91 +
1.92 "Return a program representation."
1.93 +
1.94 # NOTE: To be implemented with proper quoting.
1.95 b = buffer(['"', self, '"'])
1.96 return str(b)