Re: [Tutor] Re: A simpler mousetrap

2004-12-19 Thread Alan Gauld
> Also, just as interesting, yet probably less reliable: > > a = list(a) > a[-3:] = 'bak' > a = "".join(a) > The problem with all of these versions is they assume the extension will be three characters long. In DOS it could be *up to* three characters, but in Windows post 95 the extension can be

Re: [Tutor] Re: A simpler mousetrap

2004-12-19 Thread Alan Gauld
Rats, a premature posting sorry. > > Also, just as interesting, yet probably less reliable: > > > > a = list(a) > > a[-3:] = 'bak' > > a = "".join(a) > > > The problem with all of these versions is they assume the > extension will be three characters long. In DOS it could be *up to* > three charac

Re: [Tutor] Re: A simpler mousetrap

2004-12-18 Thread Jacob S.
Also, just as interesting, yet probably less reliable: a = list(a) a[-3:] = 'bak' a = "".join(a) OR a = a.rstrip('pct') a = a+'bak' OR a = a.rstrip('pct')+'bak' ## Which is essentially the same thing OR a = a[:-3]+'bak' ETC. HTH, Jacob > x=os.path.splitext(a)[0]+'.bak' > > Ah, jolly good

Re: [Tutor] Re: A simpler mousetrap

2004-12-16 Thread Liam Clarke
x=os.path.splitext(a)[0]+'.bak' Ah, jolly good, looks a bit simpler. Thanks! Regards, Liam Clarke On Thu, 16 Dec 2004 09:44:03 +0100, Wolfram Kraus <[EMAIL PROTECTED]> wrote: > Liam Clarke wrote: > > Hi all, > > > > I'm writing some code, and I want to take a given path + filename, and > > chan

[Tutor] Re: A simpler mousetrap

2004-12-16 Thread Wolfram Kraus
Liam Clarke wrote: Hi all, I'm writing some code, and I want to take a given path + filename, and change the file extension to *.bak. In doing so, (entirely internal this function), I am assuming - That the file will always have an extension Thathe extension will vary But, it will follow the gene