[FRPythoneers] looking for help with elementtree
sgillies at frii.com
Sat Jun 28 07:39:16 MDT 2003
On Friday, June 27, 2003, at 09:13 PM, Tom Hall wrote:
> On Fri, Jun 27, 2003 at 06:59:02PM -0600, Sean Gillies wrote:
>> Nevermind ... found the problem.
> Well, what was it !
I'm looking for a sub-element tagged 'ENVELOPE' within a
'PROPERTIES' element, so I do:
envelope = properties.find('ENVELOPE')
Then I write code to go on and do something with this new
element after testing that it's been found:
envelope doesn't seem to evaluate to true as it should.
if envelope is not None:
my code executes as intended. According to 5.10 of the reference
In the context of Boolean operations, and also when expressions are
used by control flow statements, the following values are interpreted
as false: None, numeric zero of all types, empty sequences (strings,
tuples and lists), and empty mappings (dictionaries). All other values
are interpreted as true.
In my case, envelope has no child elements, so perhaps it is being
evaluated as an empty sequence in the 'if' context?
Overall, I'm finding elementtree extremely handy for dealing with
small XML documents.
sgillies at frii dot com
More information about the FRPythoneers