How to call a function stored in another file from a Python program?
<p>If I have a text file that contains a python function definition, how can I make the function call from another Python program. Ps: The function will be defined in the Python program that does the call. </p>

<p>Ways in which can be done:</p>

<ol>
<li><p>Consider the python function as a module and call it. Constraint here is that I have to convert a python bare function into a module which would give errors. </p></li>
<li><p>Insert the code(function code) into the program that calls the function. </p></li>
</ol>

<p>Which would be the better way to go about it?</p>

<p>Edit: Thank you for all the replies. Have shed a lot of light on the initial confusion I myself had. Another doubt would be, what if the person(Obviously, not me) has written a os.system("rm -rf"). And I end up executing it. That would mean doomsday for me, right?</p>

<p>Edit2: As a lot of you have asked me to use exec, I would like to point to the this <a href="http://www.reddit.com/r/Python/comments/ex54j/seeking_clarification_on_pylonsturbogearspyramid/c1bo1v5" rel="nofollow">thread</a> and most particularly the namespace problem. It gives user a lot of chances to "circumvent" python. Don't y'all think?</p>
