Присвоить логическое значение класса в PythonPython

Программы на Python
Anonymous
Присвоить логическое значение класса в Python

Сообщение Anonymous »


If statements in Python allow you to do something like:

if not x: print "X is false." This works if you're using an empty list, an empty dictionary, None, 0, etc, but what if you have your own custom class? Can you assign a false value for that class so that in the same style of conditional, it will return false?


Источник: https://stackoverflow.com/questions/978 ... -in-python

Вернуться в «Python»