Re: [Tutor] getting filen basename without extension

2008-01-11 Thread Tiger12506
I would always use the os functions to find the basename, but You could exploit the fact that Windows considers the extension to be whatever is after the last "." character. fn = fn[:fn.rfind(".")] >> > What I found is this: >> > import os >> > myfile_name_with_path = 'path/to/my/testfile.txt' >

Re: [Tutor] getting filen basename without extension

2008-01-10 Thread Timmie
> > What I found is this: > > import os > > myfile_name_with_path = 'path/to/my/testfile.txt' > > basename = os.path.basename(myfile_with_path) > > filename = os.path.splitext(basename) > > myfile_name_without_suffix = filename[0] > > The last two can be easily combined as: > > > myfile_name_with

Re: [Tutor] getting filen basename without extension

2008-01-10 Thread Alan Gauld
"Timmie" <[EMAIL PROTECTED]> wrote > What is the easiest and fastes way to get the basename > of a file wihout extension? > > What I found is this: > import os > myfile_name_with_path = 'path/to/my/testfile.txt' > basename = os.path.basename(myfile_with_path) > filename = os.path.splitext(basen

Re: [Tutor] getting filen basename without extension

2008-01-10 Thread Rolando Pereira
Timmie wrote: > Hello, > I would like to get the name of a file without it's extension/suffix. > > What is the easiest and fastes way to get the basename > of a file wihout extension? > > What I found is this: > import os > myfile_name_with_path = 'path/to/my/testfile.txt' > basename = os.path.ba

[Tutor] getting filen basename without extension

2008-01-10 Thread Timmie
Hello, I would like to get the name of a file without it's extension/suffix. What is the easiest and fastes way to get the basename of a file wihout extension? What I found is this: import os myfile_name_with_path = 'path/to/my/testfile.txt' basename = os.path.basename(myfile_with_path) filename