13.2. Some Python Features Used in the xFS Application

Before we delve into the code of xFS, we will take a look at some Python features that we have not yet encountered.

13.2.1. Getting Filesystem Information with the os and stat Modules

The xFS application code makes use of a function in Python's standard os module called stat. Given a filename, the stat function returns a list containing 10 useful pieces of information about the file.

CD-ROM reference=13003.txt
>>> import os
>>> os.stat("xmlc.c")
(33206, 0, 2, 1, 0, 0, 4382, 934758000, 928768362, 928768947)

A quick way to find out what each of the numbers means is to print out the docstring for the stat function:

CD-ROM reference=13004.txt
>>> print os.stat.__doc__ stat(path) --> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime) ...

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.