seperating directories from files

Diez B. Roggisch deets at nospam.web.de
Mon Jan 30 16:30:19 CET 2006


> It's not what you are looking for here, but os.stat gives you access to
> lots of information about files.  In Linux and Windows, though, the
> 'type' of a file is incorporated into its filename through an extension.

No, only in windows. Under linux/unix in general there might exist the
file-command, which is basically a heuristic approach to the problem by
scanning for magic numbers and the like. Should be installed on any decent
system.

I'm not aware of a wrapping of "file" for python, and as the search terms
are pretty non-descriptive a quick google search hasn't enlightend me. But
you could always go for subprocess and invoke file, of course.

Diez



More information about the Python-list mailing list