What you want to do is use the fnmatch python module.

for i in nuke.allNodes("Write"):
    if fnmatch.fnmatch(i['name'].value(), "tiffWrite*"):
        # Do stuff

fnmatch has two useful function:

fnmatch(string, pattern)
This will return True or False depending on whether string matches
pattern

filter(listOfStrings, pattern)
This will return a list of all of the strings in listOfStrings that
match the pattern.


You can generally use any pattern style that you can use in glob (or on
the commandline)

So '*' to match 0 or more characters. ? to match just one character,
[0-9] to match any digit, [a-z] to match any lowercase letter, [a-zA-Z]
to match any letter, etc...


Hugh

On Wed, 2011-03-16 at 13:10 -0700, Brogan Ross wrote:

> So I think this should be pretty simple to answer.  I'm trying to put
> a wildcard in a string and it doesn't seem to work.  I have a bunch of
> write nodes with the base name tiffWrite_  and then followed by a
> short element description.  I'm trying to single out all the write
> nodes with tiffWrite in the name but I don't know how to get a
> wildcard to work in a string with nuke.
> Here's an example:
> For i in nuke.allnodes('Write'):
>   if i['name'].value() == 'tiffWrite*':
>      Select
> 
> Thanks.
> 
> 
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to