Ever thought about writing a script that prints its name on startup. It's pretty straightforward. You have probably noticed programs where the main function is written like this
int main (int argc, char ** argv)
and you must have wondered what these 2 arguments.
To print the name of the program, all we have to do is strip the filename from this path.
Below is the implementation of the idea discussed above in python. Let's assume the script name — print_my_name.
Note . The output will be different if you run it on the Python.Engineering online compiler.
This article courtesy of Palash Nigam . If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you'd like to share more information on the topic discussed above.