I have been looking at various open source GitHub Python projects like,
http-prompt
and Theano
What I am not able to figure out is where their starting points are, so that I can debug them gracefully. Do I need to look in each and every file for the __main__
method?
I am from Android background; so I was searching something related like AndroidManifest.xml
from where I can get an idea as where the code is getting started, but I was unsuccessful in my attempts.
There are two ways a Python script can be loaded:
import mymodule
$ python mymodule.py
In both cases all code inside the script is executed
Usually if __name__ == '__main__':
defines the entry point :
if __name__ == '__main__':
print('Started from commandline')
else:
print('Imported as a module')
In a git project, you can try this to find all scripts made to be launched from command-line :
$ git grep "if __name__ ?== ?\W__main__\W"
Note that the project you mentioned, doesn't contain any explicitly defined entry point, instead the entry point script is generated at packaging time for distribution (see setup.py
for this purpose)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With