Reading Soap struct type

Simon Brunning simon at brunningonline.net
Wed May 10 04:00:10 EDT 2006


On 5/10/06, Diez B. Roggisch <deets at nospam.web.de> wrote:
> That is because it is no hash - AFAIK SOAP doesn't support hashes (or
> dicts, in python-lingo) out of the box. What you see above essentially a
> named tuple. Conceptionally like this:
>
> class MyStruct:
>
>      def __init__(self, foo, bar):
>           self.foo = foo
>           self.bar = bar
>
>
> Either you access the individual values by name - or maybe there is a
> way to enumerate the names for you, but that depends on what the
> SOAPpy.Types.structType is capable of. I suggest you look at it's source.

IIRC, SOAPpy's structType has a _keys() function - so somethign like
the following (untested) might work:

struct_as_a_dict = dict((key, getattr(struct, key)) for key in struct._keys())

--
Cheers,
Simon B,
simon at brunningonline.net,
http://www.brunningonline.net/simon/blog/



More information about the Python-list mailing list