I'm just starting to learn Python and I'm having a hard time testing things out in the terminal. What I want to do is simply run a pre-written Python method in the Python interpreter. (I know how to run it by doing python file_name.py, but I want to run it in the interpreter itself).
So if I for example had the file "exampleModule.py":
def exampleFunc(data):
print(data)
Then in the terminal I run Python and do:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import exampleModule
>>> exampleFunc('Hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'exampleFunc' is not defined
The thing that I don't get about this is that if I run the module in the Python IDLE, I can access the exampleFunc, but not in the terminal interpreter.
Thanks!