PDA

View Full Version : Using custom functions from the Python command line



goseph
March 19th, 2010, 02:02 PM
Hi everyone!

How can I call functions / create objects etc. from the command line

ie.

"> python test.py"

works fine but:

"> python
"Welcome to python etc.
>>> test.py
I don't know what test is"

does not work.

blazemore
March 19th, 2010, 02:36 PM
Hi everyone!

How can I call functions / create objects etc. from the command line

ie.

"> python test.py"

works fine but:

"> python
"Welcome to python etc.
>>> test.py
I don't know what test is"

does not work.
execfile("test.py")

raydeen
March 19th, 2010, 02:53 PM
You can also use import to bring in modules and functions.



>>> import math


will bring in all the math functions to use in the interactive session.

goseph
March 19th, 2010, 04:42 PM
Thanks for that chaps!