Values that seems equal fails at comparison?


print(b)
# 
bpy.ops.mesh.z_put_on(turn=0)


print(c)
[# 
bpy.ops.mesh.z_put_on(turn=0)]


print(b == c[0])
False

Does anyone know what is the culprit here?

#UPDATE:

I walked around this problem with great result for the addon I’m working on, but I’m still curious of what’s the explanation of such situation. If anyone know, I’ll be glad to hear about the insights.

last one seems to be part of a list
first is not !

happy bl

But I used ‘c[0]’ to point at the member of that list, which the member is the same thing as ‘b’

If being a member of a list changes the identity, then this would make sense. Though I have no clue as to how to compare these 2 to make sure they recognize each other and give a workable result.

Where are you assigning the values? The code you posted doesn’t say much.

https://github.com/TeaCrab/0Tea_deCypher_Kit/tree/test

I’m working on this addon. I’m implementing a filter/search function for the menu generator.

If you try the addon and go to bpy.ops.mesh, the filter/search menu will show, and what I’m asking here is a part of the problem I’m having when implementing this feature.

Now, there were a different approach I used before that worked, but the order of the results are bad. If you look at the code, you will find a few global variable.

One called ‘subject’ and the other is called ‘subject_filtered’.

The subject is the pointer to any attribute that could be in any module.

The subject_filtered is a list that is used to contain any filtered pointers to all attributes that’s inside the subject.

The old method I used is to generate a menu from the subject_filtered. As I’ve said, it doesn’t give me a good ordered result, and I haven’t found a good way to sort it.

The new method I’m using is to generate a menu from the original subject, the loop looks like this:


for item in dir(subject):
    if getattr(subject, item) in subject_filtered:
        # generates menu

Which, the problem I described above happens, causing the menu to display nothing. Because none of this check returns true even though it gives me the same thing when I typed such command in the pyConsole in blender.

#Note:

Everything is doing what they are supposed to do exactly when I debugged. Except the identity check… That part is definitely doing something I don’t quite understand yet.

Forgive me if it’s something stupid… I’ve only started coding not long ago.

#Note2:

I walked around the issue by moving the condition check into the menu generation directly. Now instead of getting a list of filtered items, I don’t need the list at all. The menu generator now checks if there is any filter condition and show/hide the filtered items at the time of generation.