Wildcards

So I’m making a script, that iterates through all the objects in a scene, but I want it to perform the function only on objects with a certain suffix.

if blab == “*bla”

It doesn’t seem to like the wildcard, I assume I must be using it wrong?

I mean I’m not getting a syntax error as its in a string and it searching for an object called “*bla” in this example.

thanks

I just realized I could the out liner so that does help a bit, but I would really love if someone explained wildcards to me, I’ve never used them before. I get what they do but are there rules about there usage in blender?

You can’t do var == “wildcard_string” in python, there’s a blender operator though that accepts wildcard strings (select_pattern)

if you wanna check for a suffix with python:

for ob in bpy.context.selected_objects:
    if ob.type == 'MESH' and ob.name.endswith("_this_suffix"):
        print("Mesh that ends with the required suffix - %s" % ob.name)

Huh, I never would have thought to look for something like .endswith

Thank you

http://docs.python.org/3.3/library/stdtypes.html#string-methods :slight_smile:

Thanks I really appreciate that, I do need to take the time to actually learn python.