>>> x = 0
>>> if not x == 3: print 'x does not equal 3'
x does not equal 3
Позвольте мне объяснить подробнее:
>>> list = [-1, 1, 2, 3]
>>> if not all(n > 0 for n in list): print 'a value is not greater than zero'
a value is not greater than zero
# => or shorter ...
>>> if min(list) < 0: print 'a value is not greater than zero'
a value is not greater than zero
обратите внимание, что list
является встроенным и не должен использоваться в качестве имени переменной.
>>> list
<type 'list'>
>>> list = [1, 2, "value not greater than 0"]
>>> list
[1, 2, "value not greater than 0"]
>>> del list
>>> list
<type 'list'>
...