Skip to content

Instantly share code, notes, and snippets.

View Imxset21's full-sized avatar

Pedro Rittner Imxset21

View GitHub Profile
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):