Your right, thanks for the speed tip...

On Thu, May 19, 2011 at 3:37 AM, Amorano <[email protected]> wrote:

> Hey!
>
> There is no need to check the lengths if the keys match:
>
> def isEquivalent(self, other):
>         if self is other:
>                return True
>         try:
>                 if self.keys() == other.keys():
>                         v = [v.index for v in self.values()]
>                        o = [o.index for o in other.values()]
>                         return v == o
>         except StandardError, Err:
>                print Err
>        return False
>
> On May 18, 9:56 am, thirstydevil <[email protected]> wrote:
> > Something that would have been useful for me today on the Enum class.
> > I tried overriding __eq__ but that resulted in recursion errors, I
> > have no idea why so I just renamed the function.
> >
> > def isEquivalent(self, other):
> >         try:
> >             if self is other:
> >                 return True
> >             elif len(self) == len(other):
> >                 v = [v.index for v in self.values()]
> >                 oV = [o.index for o in other.values()]
> >                 if oV != v:
> >                     return False
> >                 if self.keys() != other.keys():
> >                     return False
> >                 return True
> >             else:
> >                 return False
> >         except StandardError, Err:
> >             print Err
> >             return False
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>



-- 
David Moulder
http://www.google.com/profiles/squish3d

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to