0
私xml
ファイルされる:私はsrai
のbool値をチェックするときPythonのElementTreeのXML解析:要素オブジェクトのbool値は、このような奇妙な
<aiml>
<category>
<pattern>*test*</pattern>
<template><srai>test</srai></template>
</category>
</aiml>
トラブルはそれが偽
(Pdb) not srai_tag
True
(Pdb) srai_tag
<Element 'srai' at 0x10e08fea8>
(Pdb) not template
False
(Pdb) template
<Element 'template' at 0x10e08fe58>
私を返し、ありますPythonのバージョンは3.6.1です。
クラスは自由にTrue/Falseを定義できます。 'Element'クラスがそれをどのように定義しているか知っていますか? –
ああ、将来のバージョンでは '__bool__'メソッドを変更します。 –