I would like to know if there is a way to directly run a python function directly from a file by just mentioning the filename followed by the function in a single line.
For example, lets say I have a file 'test.py' with a function 'newfunction()'.
----------test.py-----------
def newfunction():
print 'welcome'
Can I run the newfunction() doing something similar to this.
python test.py newfunction
I know how to import and to call functions etc.Having seen similar commands in django etc (python manage.py runserver
), I felt there is a way to directly call a function like this. Let me know if something similar is possible.
I want to be able to use it with django. But an answer that is applicable everywhere would be great.