As Ron said, use list.append to add another item. I believe += is the operator 
overload for list.extend, and since a string is actually a sequence, each of 
its elements (characters) is added to the list individually.

To get rid of your file extension, just use os.path.splitext.

import os
fName = '01_sweetTree_v001.nk'
namePart = os.path.splitext(fName)[0]

-Nathan


On May 31, 2012, at 8:27 AM, "Ron Ganbar" <[email protected]> wrote:

> list = [0, 1]
> list.append(2)
> print list
> ->> [0,1,2]
> 
> if memory serves.
> 
> Ron Ganbar
> email: [email protected]
> tel: +44 (0)7968 007 309 [UK]
>      +972 (0)54 255 9765 [Israel]
> url: http://ronganbar.wordpress.com/
> 
> 
> 
> On 31 May 2012 18:08, Noggy <[email protected]> wrote:
> Few more questions on this topic.
> 
> I got my path split now into a list using; wPath.split('/')[:2]
> That returns a list; ['C:', 'shotFolder']
> How do I add another item to the list? I try just += a string variable but 
> each character is treated as a string in the list giving me; ['C:', 
> 'shotFolder', 'r', 'e', 'n', 'd', 'e', 'r']
> There's some kind of concatenation syntax I'm missing.
> 
> 
> Also, if I have a filename like "01_sweetTree_v001.nk". What's the easiest 
> way to get rid of ".nk"? That way I'm left with just the filename, 
> "01_sweetTree_v001"?
> 
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> 
> 
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to