Good point Frank. os.sep is better than hardcoding it to both split and
join.

On Tue, May 15, 2012 at 2:09 PM, Ean Carr <[email protected]> wrote:

> I might add... if you know you'll always be dealing with windows paths,
> you can hard-code the sep, but I like to use the os.sep to join my path
> list back up variable for cross-platform compatibility. For example:
>
> import os
> filePath_list = ['', 'Volumes', 'Something1', 'Something2', 'Something3',
> 'Something4', 'Somefile.%04d.dpx']
> os.sep.join(filePath_list)
>
> -Ean
>
>
> On Tue, May 15, 2012 at 4:34 PM, Diogo Girondi <[email protected]>wrote:
>
>> You could split it into a list, slice it and then join it into a string
>> again:
>>
>> filePath = '/'.join(
>> '/Volumes/Something1/Something2/Something3/Something4/Somefile.%04d.dpx'.split(
>> '/' )[:4] )
>>
>>
>>
>> - diogo
>>
>> On Tue, May 15, 2012 at 11:41 AM, Noggy <
>> [email protected]> wrote:
>>
>>> **
>>> I'm trying to take a filePath similar to the one below and trying
>>> replace everything after the 3rd slash. Is there a command that filters
>>> through a string from left to write and return how many \ there are? I'm
>>> thinking of creating a slashVar to use in a simple loop, this can tell me
>>> how far into a path I am. If slashVar has a value of 3, that means I'm in
>>> the render folder. I'm having trouble finding the right command that does
>>> this.
>>>
>>> C:\jobName\shot\render\myRenders.####.dpx
>>>
>>> _______________________________________________
>>> 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
>
>
_______________________________________________
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