Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Python 2.6.5 では、dbm のインスタンスに __nonzero__ または __len__ メソッドがないのに、なぜ false をブール値として評価するのですか?
>>> a = dbm.open( 'foo', 'c' ) >>> if a: print 'true' ... >>>
Pythonのドキュメントによると、falseと見なされる値のタイプの1つは
などの空のマッピング{}。
{}
オブジェクトはdbmマッピングであり、新しいインスタンスは空であるため、false です。
dbm