Use the ls()
commands to find objects by name:
freds = cmds.ls("fred")
#finds all objects in the scene named exactly 'fred', ie [u'fred', u'|group1|fred']
Use *
as a wildcard:
freds = cmds.ls("fred*")
# finds all objects whose name starts with 'fred'
# [u'fred', u'frederick', u'fred2']
has_fred = cmds.ls("*fred*")
# [u'fred', u'alfred', u'fredericka']
ls() takes multiple filter string arguments:
cmds.ls("fred", "barney")
# [u'fred', u'|group1|barney']
It can also accept an iterable argument:
look_for = ['fred', 'barney']
# cmds.ls(look_for)
# [u'fred', u'|group1|barney']