eliben wrote:
... a prety good try ...
def parse_path(path):
"""..."""
By the way, the comment is fine. I am going for brevity here.
lst = []
while 1:
head, tail = os.path.split(path)
if tail == '':
if head != '': lst.insert(0, head)
break
"Mark Tolonen" <[EMAIL PROTECTED]> wrote:
>> Can you recommend a generic way to achieve this ?
>> Eli
>
import os
from os.path import normpath,abspath
x=r'\foo\\bar/baz//spam.py'
normpath(x)
> '\\foo\\bar\\baz\\spam.py'
normpath(abspath(x))
> 'C:\\foo\\bar\\baz\\spam.py'
"eliben" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
On Jun 7, 10:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> You can just split the path on `os.sep', which contains the path
> separator of the platform on which
On Sat, 07 Jun 2008 02:15:07 -0700, s0suk3 wrote:
> On Jun 7, 3:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
>> On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
>> > You can just split the path on `os.sep', which contains the path
>> > separator of the platform on which Python is ru
On Jun 7, 3:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> > You can just split the path on `os.sep', which contains the path
> > separator of the platform on which Python is running:
>
> > components = pathString.split(os.sep)
>
> W
On Jun 7, 10:15 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> > You can just split the path on `os.sep', which contains the path
> > separator of the platform on which Python is running:
>
> > components = pathString.split(os.sep)
>
>
On Fri, 06 Jun 2008 23:57:03 -0700, s0suk3 wrote:
> You can just split the path on `os.sep', which contains the path
> separator of the platform on which Python is running:
>
> components = pathString.split(os.sep)
Won't work for platforms with more than one path separator and if a
separator is
On Jun 7, 12:55 am, eliben <[EMAIL PROTECTED]> wrote:
> Hello,
>
> os.path.split returns the head and tail of a path, but what if I want
> to have all the components ? I could not find a portable way to do
> this in the standard library, so I've concocted the following
> function. It uses os.path.s
Hello,
os.path.split returns the head and tail of a path, but what if I want
to have all the components ? I could not find a portable way to do
this in the standard library, so I've concocted the following
function. It uses os.path.split to be portable, at the expense of
efficiency.
-