Ok first bit of a background.
So.. right now, I have a code say( loop.py) which is nothing but a big for loop... which takes in input for stdin and do some manipulation to that string and then i write the output.
so something like
#loop.py
from clean import *
for line in sys.stdin:
clean_line = clean(line)
print clean_line
And I run this as
cat input.txt | python loop.py
So, clean.py is certain cleaning logic which user writes.
Now, here we have a "clean" function.. for some it is certain extraction logic..
so you may have
#loop.py
from clean import *
for line in sys.stdin:
extract_line = extract(line)
print extract_line
Now, this loop.py hasnt changed.. and it will not change..
So.. maybe i can spell out the experience and someone can help me figure out how to implement that..
What I want is user to write those custom functions..So user writes...
my_custom_func.py
import run_loop
def my_own_logic(string):
# my logic goes in here
run_loop.run(my_own_logic)
and what this does is automatically execute the loop.py and this my_own_logic function is pushed in that loop?
I hope I am making any sense... Am i?