[Fedora-suds-list] Checking for the existence of elements in a response

Brandon Pedersen bpedman at gmail.com
Sun Sep 12 20:30:18 UTC 2010


if hasattr(result, 'FirstField') and hasattr(result.FirstField,
'SomeTable') and hasattr(result.FirstField.SomeTable, 'SomeData') and
so on:
    info = that thing

On Sun, Sep 12, 2010 at 3:21 AM, Rob D <robzyb at gmail.com> wrote:
> Hey, a big thanks to Jeff for helping me figure out how to use the Doctor :)
> It was much appreciated.
>
> I currently have a bit of a problem, though. I have looked through the
> documentation and can't seem to find out what object client.service returns.
> This is my code:
>
> result = client.service.DoSomethingIncrediblyInteresting(WithADiscoStick)
> info =  result.FirstField.SomeTable.SomeData.somethingorother.DooDah
>
> The thing is that sometimes FirstField doesnt exist which causes my Python
> program to quit rather angrily. Is there a check I can do on result,
> FirstField, and so on, to check of the children I'm about to grab info from
> actually exist?
>
> Thanks,
> Rob.
>
> _______________________________________________
> suds mailing list
> suds at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/suds
>


More information about the suds mailing list