PyPI Package filehandlers
filehandlers is a library for working with files.
filehandlers is built on a simple model.
A file is represented with an instance of
The file doesn't need to exist when creating an instance of
Now, say you want to change that file... that is where
filehandlers.FileManipulator comes in.
You need to pass the
AbstractFile instance when creating a
FileManipulator so filehandlers knows exactly
which file it is controlling.
The manipulator includes code for a number of common functions that you may find handy.
Here is a quick example that shows how to use filehandlers to write to a file:
from filehandlers import FileManipulator, AbstractFile # define the filemy_cool_file = AbstractFile("log.txt") # create FileManipulatormy_cool_files_changer = FileManipulator(my_cool_file) # write data to file 5 timesfor i in range(5): my_cool_files_changer.write_to_file("Message #" + i + ": " + debug_message)
You can see the full API documentation here.
The source can be found on GitHub.