1
我正在嘗試定義一個自定義元類型以用於typehinting。例如類型提示的自定義元類型
print(Tuple[int, str, bool])
print(CustomType[int, str, bool])
第一行很好,很明顯。我將如何實施CustomType
,以便它也可以工作?我試過這個:
class CustomType(Tuple):
pass
並得到錯誤TypeError: __main__.CustomType is not a generic class
。 我的目標是有元組的專業化與附加類方法