[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debian Maintainer application



Anthony Towns wrote:
> 
> Uh, rsplit and split don't do the same thing:
> 
>     >>> x = "foo bar baz"
>     >>> x.split(" ", 1)
>     ['foo', 'bar baz']
>     >>> x.rsplit(" ", 1)
>     ['foo bar', 'baz']
> 
>     >>> x = 'foo***bar'
>     >>> x.split("**")
>     ['foo', '*bar']
>     >>> x.rsplit("**")
>     ['foo*', 'bar']


>>> file = "doc/en/index.cache.bz2"
>>> list = file.split('/')
>>> print list[0]
doc
>>> print list[1]
en
>>> print list[2]
index.cache.bz2
>>> list = file.rsplit('/')
>>> print list[0]
doc
>>> print list[1]
en
>>> print list[2]
index.cache.bz2

Unless I completely missunderstood something somewhere the second part
should show the path components in reverse order.

> 
> If you want a pythonic way of getting the basename, you want:
> 
>     import os
>     os.path.basename(file) == 'index.cache.bz2'

Nice, thanks

> 
> Don't blame the language for your own unfamiliarity with it.
> 
> Cheers,
> aj

Cheers,
-- 
Atomo64 - Raphael

Please avoid sending me Word, PowerPoint or Excel attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


Reply to: