[size=x-large]
http://wiki.python.org/moin/ByteplayDoc
-----------------------
wget http://byteplay.googlecode.com/svn/trunk/byteplay.py
-----------------------
from types import FunctionType
from byteplay import Code, opmap
def _transmute(opcode, arg):
if ((opcode == opmap['LOAD_GLOBAL']) and
(arg == 'request')):
return opmap['LOAD_FAST'], arg
return opcode, arg
def requestless(function):
code = Code.from_code(function.func_code)
code.args = tuple(['request'] + list(code.args))
code.code = [_transmute(op, arg) for op, arg in code.code]
function.func_code = code.to_code()
return function
@requestless
def test():
print request
test(123)[/size]