I would like to know if there is a way to directly run a python function directly from a file, just by mentioning the file name followed by the function on one line.
For example, let's say I have a test.py 'file with the newfunction () function.
---------- test.py -----------
def newfunction(): print 'welcome'
Can I run the newfunction () function to do something like this.
python test.py newfunction
I know how to import and call functions, etc. If you saw similar commands in django etc. ( python manage.py runserver ), I felt that there was a way to directly call such a function. Let me know if something like this is possible.
I want to use it with django. But the answer that applies everywhere would be great.
source share