moff4 / PycEditor

Tool for editing PYC files and Python bytecode in runtime

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PycEditor

Build Status

Tool for editing .pyc files and Python bytecode in runtime.

Example:

"Some code":

def f():
    print('Hello World')

Editing this "some code"

import random
import pyceditor
pyc = pyceditor.PycFile.load_from_pycode(f.__code__)
x = random.randint(15, 10**4)
pyc.code.co_consts = (None, 'Hi! Random number: %d' % x)
eval(pyc.pycode)
# prints random number

Buy Me A Coffee

About

Tool for editing PYC files and Python bytecode in runtime

License:MIT License


Languages

Language:Python 100.0%