Хотя правильные текущие ответы потенциально не завершены.
eg
a = TestClass()
b = a - 5
print type(b)
Показать b как целое число, где вы можете захотеть, чтобы это был TestClass.
Вот улучшенный ответ
class positive(int):
def __new__(cls, value, *args, **kwargs):
if value < 0:
raise ValueError, "positive types must not be less than zero"
return super(positive, cls).__new__(cls, value)
def __add__(self, other):
res = super(positive, self).__add__(other)
return self.__class__(max(res, 0))
def __sub__(self, other):
res = super(positive, self).__sub__(other)
return self.__class__(max(res, 0))
def __mul__(self, other):
res = super(positive, self).__mul__(other)
return self.__class__(max(res, 0))
def __div__(self, other):
res = super(positive, self).__div__(other)
return self.__class__(max(res, 0))
Теперь тот же самый тип теста
a = positive(10)
b = a - 9
print type(b)
будет печатать «положительный»
Вы должны поместить все свои общедоступные страницы в папку public_html
. Это основная точка входа или корень вашего доменного имени. Также переименуйте файл Index.html
в index.html
.