36
가능한 중복 :이 "거짓"인쇄한다고 생각
defining “boolness” of a class in python파이썬의 __bool__ 메소드를 오버로드하는 방법은 무엇입니까?
, 왜이 "참"인쇄한다?
>>> class Foo(object):
... def __bool__(self):
... return False
...
>>> f = Foo()
>>> if f:
... print "True"
... else:
... print "False"
...
True
>>>
[사용자 정의 클래스에 대한 bool() 덮어 쓰기] (http://stackoverflow.com/questions/2233786) – outis