Skip to content
Inject variables into a python function at call time
Find file
Pull request Compare This branch is even with objcode:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README.md
inject.py
test_inject.py

README.md

Inject python locals

A bit of hackery to experiment with alternative call flow in python.

To use:

def foo():
    print a

inject(a=5).into(foo)
>> 5

@inject(cat='man')
def bar():
    print "the cat is a", cat

bar()
>> the cat is a man

@inject(a=5)
def baz(a=6):
    print a

baz()
>> 5

Q: Why should I use this?

A: You shouldn't

Q: Why does it exist?

A: Because it can

Q: Are you crazy?

A: ?

Q: Is it good?

A: yes

Something went wrong with that request. Please try again.