On 2013-04-29, Neil Cerutti <ne...@norwich.edu> wrote:
> find returns None when it doesn't find what you asked for. So you
> can't check the .text attribute right away unless you want an
> exception thrown. I deal with these annoyances like this:
>
> sepelem = 
> content.find(".//{http://www.huawei.com.cn/schema/common/v2_1}sepid";)
> if sepelem is not None:
>    sepid = sepid.text

Oops. One edit too fiew. That line should of course be

   sepid = sepelem.text

> else:
>    sepid = ''
>
> The empty string works for my purposes. Your script might need
> something else.


-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to