Skip to content

Commit 5a3ad33

Browse files
committed
写了这么久突然发现最重要的类没有继承(
1 parent 0b01b31 commit 5a3ad33

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

type.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
对Python原版类型的扩展
33
"""
44
__author__ = "Jerry"
5-
__version__ = "1.3.2"
5+
__version__ = "1.3.3"
66

77
__all__ = ["String", "Integer", "List"]
88

99
class NotComposedOfNumbersError(Exception):
1010
"不是由数字组成的字符串使用某些方法时抛出"
1111
pass
1212

13-
class String:
13+
class String(str):
1414
"字符串类,是对Python原版字符串的加强"
1515
def __init__(self, str_) -> None:
1616
if type(str_) is not str:
@@ -124,7 +124,7 @@ def replace(self, /, past, now):
124124
return String(self.__str.replace(past, now))
125125

126126
def subString(self, /, range1, range2=None):
127-
"字符串切片。在前一个括号中填入起始索引值,后一个括号中填入结束索引值。若索引值超出了字符串范围,将会返回空字符串"
127+
"字符串切片。在前一个括号中填入起始索引值,后一个括号中填入结束索引值,将会返回一个String对象。若索引值超出了字符串范围,将会返回空字符串"
128128
if range2 is None:
129129
range2 = range1 + 1
130130
return String(self.__str[range1:range2])
@@ -151,7 +151,7 @@ def toInteger(self):
151151
"字符串不是由数字组成的"
152152
) from e
153153

154-
class Integer:
154+
class Integer(int):
155155
"整数类型,是对Python原版整数的加强"
156156
def __init__(self, int_) -> None:
157157
if type(int_) is not int:
@@ -258,7 +258,7 @@ def toString(self):
258258
"将整数转成String对象"
259259
return String(str(self.__int))
260260

261-
class List:
261+
class List(list):
262262
"列表类型,是对Python原版列表的加强"
263263
def __init__(self, list_) -> None:
264264
if type(list_) is not list:

0 commit comments

Comments
 (0)