# Calling Python Function from Console

Would it be possible to call Python codes I wrote in Text Editor from the Python console so that I can interact with it?

If you name your script *.py in the text editor you can import it in the console as a module.

Beware - after you imported the script for the first time you can't import it again. If you make changes to the module you can use imp.reload or importlib.reload (for blender versions > 2.71 using python 3.4)

You can retrieve the Text datablock's text as string and run it in the context of the Python Console.

Here's an addon that makes it easy to do so:

• As in resetting the scrollback, history and environment (globals and locals)? Well, you can remove members from locals() and globals() and bpy.ops.console.clear() resets the scrollback, but the history stays. I tried resetting the console by splitting and joining the area, but joining is buggy. – CodeManX Jul 8 '14 at 21:40