1.1 --- a/lib/__builtins__/str.py Fri Feb 03 23:24:15 2017 +0100
1.2 +++ b/lib/__builtins__/str.py Fri Feb 03 23:25:00 2017 +0100
1.3 @@ -22,8 +22,8 @@
1.4 from __builtins__.operator import _negate
1.5 from __builtins__.sequence import hashable, itemaccess
1.6 from __builtins__.types import check_int
1.7 -from native import str_add, str_lt, str_gt, str_eq, str_len, str_nonempty, \
1.8 - str_substr
1.9 +from native import str_add, str_lt, str_gt, str_eq, str_len, str_ord, \
1.10 + str_nonempty, str_substr
1.11
1.12 WHITESPACE = (" ", "\f", "\n", "\r", "\t")
1.13
1.14 @@ -257,6 +257,15 @@
1.15
1.16 # String-specific methods.
1.17
1.18 + def __ord__(self):
1.19 +
1.20 + "Return the value of the string, if only a single character."
1.21 +
1.22 + if self.__len__() == 1:
1.23 + return str_ord(self.__data__)
1.24 + else:
1.25 + raise ValueError, self
1.26 +
1.27 def endswith(self, s):
1.28
1.29 "Return whether this string ends with 's'."