2015-01-29 00:44:11 +00:00
|
|
|
x = 1
|
|
|
|
print(+x)
|
|
|
|
print(-x)
|
|
|
|
print(~x)
|
|
|
|
|
2014-01-27 23:15:32 +00:00
|
|
|
print(not None)
|
|
|
|
print(not False)
|
|
|
|
print(not True)
|
|
|
|
print(not 0)
|
|
|
|
print(not 1)
|
|
|
|
print(not -1)
|
|
|
|
print(not ())
|
|
|
|
print(not (1,))
|
|
|
|
print(not [])
|
|
|
|
print(not [1,])
|
|
|
|
print(not {})
|
|
|
|
print(not {1:1})
|
2015-12-08 12:34:25 +00:00
|
|
|
|
|
|
|
# check user instance
|
|
|
|
class A: pass
|
|
|
|
print(not A())
|
|
|
|
|
|
|
|
# check user instances derived from builtins
|
|
|
|
class B(int): pass
|
|
|
|
print(not B())
|
|
|
|
class C(list): pass
|
|
|
|
print(not C())
|