Suppose we want to write a program that prints its own name in python for data science. The main function will be written in the following manner.
Now we should understand the arguments given in the program above.
- The argument, argc is number of arguments pass in our program.
- The argument argv is array for holding the names of arguments pass in our program.
- We have an extra piece of information store in the first cell of the array.
For printing the name of the program we have to slice the filename out of the path.
Now we will see the implementation. Let us suppose name of the script is print_my_name.