def apply_to_binary_file(f):
 @wraps(f)
 def f_in_file(fname):
  with open(fname, 'rb') as inf:
   data = inf.read()
  data = f(data)
  with open(fname, 'wb+') as outf:
   outf.write(data)
 return f_in_file

def apply_to_binary_file ( f ) : @ wraps ( f ) def f_in_file ( fname ) : with open ( fname , 'rb' ) as inf : data = inf . read ( ) data = f ( data ) with open ( fname , 'wb+' ) as outf : outf . write ( data ) return f_in_file
apply a filter to a binary file .