Re: How to get the extension of a filename from the path

2005-12-09 Thread Tom Anderson
On Thu, 8 Dec 2005, gene tani wrote: > Lad wrote: > >> what is a way to get the the extension of a filename from the path? > > minor footnote: windows paths can be raw strings for os.path.split(), > or you can escape "/" > tho Tom's examp indicates unescaped, non-raw string works with > splitext(

Re: How to get the extension of a filename from the path

2005-12-08 Thread gene tani
Lad wrote: > Thank you ALL for help > Regards, > L. addendum: ASPN Python cookbook often has something relevant / modifiable for your needs: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81931 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52661 (in this case code from 2001 /

Re: How to get the extension of a filename from the path

2005-12-08 Thread Lad
Thank you ALL for help Regards, L. -- http://mail.python.org/mailman/listinfo/python-list

Re: How to get the extension of a filename from the path

2005-12-08 Thread Peter Hansen
Fredrik Lundh wrote: > on the other hand, for maximum portability, you can use > > f, e = os.path.splitext(filename) > if e.startswith(os.extsep): > e = e[len(os.extsep):] > if e == "txt": > ... Is there ever a time when the original `e` could evaluate True, yet not s

Re: How to get the extension of a filename from the path

2005-12-08 Thread gene tani
Lad wrote: > Hello, > what is a way to get the the extension of a filename from the path? > E.g., on my XP windows the path can be > C:\Pictures\MyDocs\test.txt > and I would like to get > the the extension of the filename, that is here > txt > > > I would like that to work on Linux also > Thank

Re: How to get the extension of a filename from the path

2005-12-08 Thread Fredrik Lundh
"Lad" <[EMAIL PROTECTED]> wrote: > what is a way to get the the extension of a filename from the path? > E.g., on my XP windows the path can be > C:\Pictures\MyDocs\test.txt > and I would like to get > the the extension of the filename, that is here > txt > > I would like that to work on Linux a

Re: How to get the extension of a filename from the path

2005-12-08 Thread Tom Anderson
On Thu, 8 Dec 2005, Lad wrote: > what is a way to get the the extension of a filename from the path? > E.g., on my XP windows the path can be > C:\Pictures\MyDocs\test.txt > and I would like to get > the the extension of the filename, that is here > txt You want os.path.splitext: >>> import os

Re: How to get the extension of a filename from the path

2005-12-08 Thread Dale Strickland-Clark
Lad wrote: > Hello, > what is a way to get the the extension of a filename from the path? > E.g., on my XP windows the path can be > C:\Pictures\MyDocs\test.txt > and I would like to get > the the extension of the filename, that is here > txt > > > I would like that to work on Linux also > Tha

How to get the extension of a filename from the path

2005-12-08 Thread Lad
Hello, what is a way to get the the extension of a filename from the path? E.g., on my XP windows the path can be C:\Pictures\MyDocs\test.txt and I would like to get the the extension of the filename, that is here txt I would like that to work on Linux also Thank you for help L. -- http://ma