def func_dump(func):
 code = marshal.dumps(func.__code__).decode('raw_unicode_escape')
 defaults = func.__defaults__
 if func.__closure__:
  closure = tuple((c.cell_contents for c in func.__closure__))
 else:
  closure = None
 return (code, defaults, closure)

def func_dump ( func ) : code = marshal . dumps ( func . __code__ ) . decode ( 'raw_unicode_escape' ) defaults = func . __defaults__ if func . __closure__ : closure = tuple ( ( c . cell_contents for c in func . __closure__ ) ) else : closure = None return ( code , defaults , closure )
serializes a user defined function .