Python元素树XML解析:元素对象';s布尔值很奇怪

Python元素树XML解析:元素对象';s布尔值很奇怪,python,xml,Python,Xml,我的xml文件如下: <aiml> <category> <pattern>*test*</pattern> <template><srai>test</srai></template> </category> </aiml> 我的python版本是3.6.1。我检查了类xml.etree.ElementTree.Element,他们将来会更改它。谢谢你的提醒

我的
xml
文件如下:

<aiml>
<category>
    <pattern>*test*</pattern>
    <template><srai>test</srai></template>
</category>
</aiml>

我的python版本是3.6.1。

我检查了类
xml.etree.ElementTree.Element
,他们将来会更改它。谢谢你的提醒

def __bool__(self):
    warnings.warn(
        "The behavior of this method will change in future versions.  "
        "Use specific 'len(elem)' or 'elem is not None' test instead.",
        FutureWarning, stacklevel=2
        )
    return len(self._children) != 0 # emulate old behaviour, for now

类可以随意定义True/False。你知道
元素
类是如何定义它的吗?哦,他们将在未来的版本中更改
\uubool\uuu
方法。
def __bool__(self):
    warnings.warn(
        "The behavior of this method will change in future versions.  "
        "Use specific 'len(elem)' or 'elem is not None' test instead.",
        FutureWarning, stacklevel=2
        )
    return len(self._children) != 0 # emulate old behaviour, for now