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

Rob D robzyb at gmail.com
Mon Sep 13 02:02:08 UTC 2010


Excellent :) Thank you. That's much nicer than the try/except I was using.

Rob.

Brandon Pedersen wrote:
> 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
>>
>>     
> _______________________________________________
> suds mailing list
> suds at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/suds
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/suds/attachments/20100913/23fa217d/attachment.html 


More information about the suds mailing list