> 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
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
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
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
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