On Mon, Jan 21, 2008 at 07:30:28PM -0600, Raphael Geissert wrote: > Anthony Towns wrote: > > On Thu, Jan 17, 2008 at 08:25:05PM -0600, Raphael Geissert wrote: > >> # do not process the cache file > >> - if file == 'index.cache.bz2': continue > >> + if file.split('/')[file.count('/')] == 'index.cache.bz2': continue > > Uh, > > file.split('/')[-1] == 'index.chache.bz2' > > would probably be better. > Although I'll try to fix the whole thing by replacing the build system it is > nice to know python does support that (I didn't want to trust anything > after having to deal with a rsplit behaving exactly has split) so thank > you. 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'] If you want a pythonic way of getting the basename, you want: import os os.path.basename(file) == 'index.cache.bz2' Don't blame the language for your own unfamiliarity with it. Cheers, aj
Attachment:
signature.asc
Description: Digital signature