check out os.path.split as well
On 16/05/12 8:51 AM, Nathan Rusch wrote:
There are a couple things you need to be aware of.
First, your string includes the ASCII control character \r. You either
need to escape your backslashes by doubling them up or use a raw string:
"C:\\workFolder\\shots\\renderFolder"
# or
r"C:\workFolder\shots\renderFolder"
Now, the reason you're hitting a SyntaxError is because your split
string is an unescaped backslash, which makes Python think you're
trying to escape a single quote inside a single-quoted string and then
failing to complete the string with another single quote. Escaping
your backslash will work, but a safer bet is to use os.sep.
import os
r"C:\workFolder\shots\renderFolder".split(os.sep)
-Nathan
*From:* Noggy <mailto:[email protected]>
*Sent:* Tuesday, May 15, 2012 1:39 PM
*To:* [email protected]
<mailto:[email protected]>
*Subject:* [Nuke-python] Re: Seeing inside a string, to replace a file
path
Thanks! Now I get it. Does split only work on a list? I am getting an
error trying to use split on a string. There's something about this
that isn't clicking for me.
wPath = "C:\workFolder\shots\renderFolder"
wPath.split('\')[:4]
SyntaxError: EOL while scanning string literal
------------------------------------------------------------------------
_______________________________________________
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