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(
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 /
Thank you ALL for help
Regards,
L.
--
http://mail.python.org/mailman/listinfo/python-list
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
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
"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
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
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
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