This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class wrap_file_function(object): | |
""" | |
Wrap a function which takes a file or a str as it's first argument. | |
If a str is provided, replace the first argument of the wrapped function | |
with a file handle, and close the file afterwards | |
Example: | |
@wrap_file_function('w') | |
def write_hi(f): |