Run python module from console

Rustom Mody rustompmody at gmail.com
Tue Sep 5 13:02:42 EDT 2017


On Tuesday, September 5, 2017 at 8:45:00 PM UTC+5:30, Andrej Viktorovich wrote:
> Hello,
> 
> I suppose I can run python module by passing module as param for executable:
> 
> python.exe myscr.py
> 
> But how to run script when I'm inside of console and have python prompt:
> 
> >>>

By and large not straightforwardly possible
At python prompt you call *functions*
At OS prompt you call apps/programs/scripts including python *scripts*
They are different with different calling conventions

However if you look up on the __name__ == '__main__' trick
you can find ways of getting both function call and script call behavior

https://stackoverflow.com/questions/419163/what-does-if-name-main-do



More information about the Python-list mailing list