Forum Discussion

Micha__Iwaszko_'s avatar
Icon for Nimbostratus rankNimbostratus
Aug 23, 2011

Problem with LocalLB.PoolMember.get_object_status()

I wonder what's wrong with pyControl (or something else) to produce such strange objects:



import time, pycontrol.pycontrol as pc


b = pc.BIGIP('host','user','pass',fromurl = True,wsdls = 'LocalLB.Pool','LocalLB.PoolMember'])


p = b.LocalLB.Pool.get_list()


s1 = b.LocalLB.PoolMember.get_object_status(p)


s2 = b.LocalLB.PoolMember.get_object_status(p)


if s1 == s2: print "Values are equal"


if repr(s1) == repr(s2): print "Reprs are equal"



And of course, You will only see the "Reprs are equal" line. Why is that? Do the they have some messed __eq__()?


2 Replies

  • I've written myself a function to achieve this, but still would be nice to have some if s1 == s2 or for i in s1: if i in s2.
  • Michael: Disclaimer - I've not actually tested this yet, but I've got an idea of what may be going on. I think what you may be dealing with is that Suds/pyControl are returning specific objects, so using s1 == s2 isn't a consistent way to compare them.



    For an example of why I say this, refer to, where there is this comment on testing equality of class instances:



    Instances of a class normally compare as non-equal unless the class defines the __cmp__() method. Refer to Basic customization) for information on the use of this method to effect object comparisons.



    But again, I've not been able to test this and validate my statements so have a look and see if this is consistent with what you're seeing. Either way, post back and we'll figure out what is going on.