Magic Filesystem API(last modified: 08 May, '07)

A different way to access the filesystem from Python

 

You could read the data from /etc/apache2/errors.conf with something like:

 

1f = file("/etc/apache2/errors.conf", "r")
2data = f.read()

But that wouldn't be very fun. The module lets you pretend that files are more or less built-in constructs, letting you do the very funky:

1node = FileSystem() /etc/apache2/errors.conf
2f = node("r")
3print f.read()

Note the lack of quotation marks -- that path isn't a string!

The script works with some very crafty operator overloading and manipulation of globals(). Its biggest limitation is that items in the path can only contain valid Python name characters and dots. If you want to access a directory or file that has other characters, just wrap that bit in a string, i.e

1FileSystem() /etc/apache2/"default-server.conf"

I wouldn't suggest actually using it in real code, obviously. It would be very slow, and could overwrite some of your global variables!