Trouble with simple blender python script

I’m writing a blender python mesh exporter, and when trying to get the material index of a polygon, I come across some odd behavior… Basically, I narrowed the problem down to this: I have 2 material variables, and if i print them, they show the exact same material, but blender will not recognize them as equal, which is essential to do a .index on a list. The relevant code is as follows:

print "_",mat[0],"_ is _",ms.materials[0],"_"
if mat[0] == ms.materials[0]:
	print "ITIS"
	print "NOT!"

which results in the output:

_ [Material "Material"] _ is _ [Material "Material"] _

and the mat and ms variables were derived from the following pieces of code:

mat = Blender.Material.Get()

ol = Blender.Object.Get()
for obj in ol:
ms = obj.getData()

I am using blender 2.40 with python 2.4. I would appreciate any feedback =] I spent a good while trying to figure this out, comparing their .class es and everything else. The only thing I can think of is their ‘=’ operators weren’t overloaded [dunno how that works in python]. If anyone needs the blender python .py, it is here:

Thanks for any help =]

Well, I found a workaround, which is to compare the materials’ .getName() values… but if anyone knows why the original happened, please respond =p

I think the object has to have a cmp or eq method to do the comparison you coded. I did not see those in the api doc.

So you would have to get/reference the property you want like the .getName() or you could convert the object to a string something like

if str(mat[0]) == str(ms.materials[0]):

Not sure which way is considered better in for this.

Thanks much =]