get Windows file type

Sybren Stuvel sybrenUSE at YOURthirdtower.com.imagination
Mon May 8 08:05:21 EDT 2006


BartlebyScrivener enlightened us with:
> Using Python on Windows XP, I am able to get almost all file and
> path info using os.path or stat, but I don't see a way to retrieve
> the file type? E.g. Microsoft Word file, HTML file, etc, the
> equivalent of what is listed in the "Type" column in the Windows
> Explorer box.

I'm afraid you'll have to get that from the registry. That will only
give you the descriptive name of the extension, though, and not the
type of contents of the file, i.e. if you have a HTML file named
'somefile.avi', Windows recognises it as an AVI and not an HTML file.

Sybren
-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself? 
                                             Frank Zappa



More information about the Python-list mailing list