def tweak_code(func, codestring=None, consts=None):
 co = func.__code__
 tp = type(co)
 if (codestring is None):
  codestring = co.co_code
 if (consts is None):
  consts = co.co_consts
 if (sys.version_info >= (3,)):
  new_code = tp(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize, co.co_flags, codestring, consts, co.co_names, co.co_varnames, co.co_filename, co.co_name, co.co_firstlineno, co.co_lnotab)
 else:
  new_code = tp(co.co_argcount, co.co_nlocals, co.co_stacksize, co.co_flags, codestring, consts, co.co_names, co.co_varnames, co.co_filename, co.co_name, co.co_firstlineno, co.co_lnotab)
 func.__code__ = new_code

def tweak_code ( func , codestring = None , consts = None ) : co = func . __code__ tp = type ( co ) if ( codestring is None ) : codestring = co . co_code if ( consts is None ) : consts = co . co_consts if ( sys . version_info >= ( 3 , ) ) : new_code = tp ( co . co_argcount , co . co_kwonlyargcount , co . co_nlocals , co . co_stacksize , co . co_flags , codestring , consts , co . co_names , co . co_varnames , co . co_filename , co . co_name , co . co_firstlineno , co . co_lnotab ) else : new_code = tp ( co . co_argcount , co . co_nlocals , co . co_stacksize , co . co_flags , codestring , consts , co . co_names , co . co_varnames , co . co_filename , co . co_name , co . co_firstlineno , co . co_lnotab ) func . __code__ = new_code
tweak the code object of the given function by replacing its *codestring* and *consts* tuple .