Re: removing extension

2008-04-27 Thread Arnaud Delobelle
Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> writes: > Not exactly. In the case of no extension `os.path.splitext()` still works: > > In [14]: 'foo/bar.txt'.rsplit('.') > Out[14]: ['foo/bar', 'txt'] > > In [15]: 'foo/bar'.rsplit('.') > Out[15]: ['foo/bar'] > > In [16]: os.path.splitext('foo/bar')

Re: removing extension

2008-04-27 Thread Marc 'BlackJack' Rintsch
On Sun, 27 Apr 2008 15:06:54 +, Matt Nordhoff wrote: > Arnaud Delobelle wrote: >> More simply, use the rsplit() method of strings: >> > path = r'C:\myimages\imageone.jpg' > path.rsplit('.', 1) >> ['C:\\myimages\\imageone', 'jpg'] >> >> > path = r"C:\blahblah.blah\images.20.jpg"

Re: removing extension

2008-04-27 Thread Matt Nordhoff
Arnaud Delobelle wrote: > More simply, use the rsplit() method of strings: > path = r'C:\myimages\imageone.jpg' path.rsplit('.', 1) > ['C:\\myimages\\imageone', 'jpg'] > > path = r"C:\blahblah.blah\images.20.jpg" path.rsplit('.', 1) > ['C:\\blahblah.blah\\images.20', 'jpg'] >

Re: removing extension

2008-04-27 Thread Arnaud Delobelle
Lie <[EMAIL PROTECTED]> writes: > On Apr 27, 6:05 pm, Lie <[EMAIL PROTECTED]> wrote: >> >> I don't know if this is the simplest way, but you can use re module. >> >> import re >> pat = re.compile(r'(.*?)\..*') > > Sorry, this line should be: > pat = re.compile(r'(.*)\..*') > > or paths like these

Re: removing extension

2008-04-27 Thread Lie
On Apr 27, 6:05 pm, Lie <[EMAIL PROTECTED]> wrote: > On Apr 27, 5:34 pm, wilson <[EMAIL PROTECTED]> wrote: > > > > > i was trying to convert all images in a folder to another type and > > save the new images in a separate folder.for that i wrote a class and > > coded some part > > > class ConvertIm

Re: removing extension

2008-04-27 Thread Lie
On Apr 27, 5:34 pm, wilson <[EMAIL PROTECTED]> wrote: > i was trying to convert all images in a folder to another type and > save the new images in a separate folder.for that i wrote a class and > coded some part > > class ConvertImgs: > def __init__(self,infldr,outfldr): >