I'm current working through Learning Python the Hard Way, and it is perhaps going a little fast for me. I've input the following code, with along with the corresponding file. In the py file, I wrote:
#!/usr/bin/python
from sys import argv
script, filename = argv
txt = open(filename)
print "Here's your file %r:" % filename
print txt.read()
print "Type the filename again:"
file_again = raw_input("> ")
txt_again = open(file_again)
print txt_again.read()
And to run it, I wrote: python script.py readme.txt
which ran the code.
However, I don't quite understand the process here:
- How come
#!/usr/bin/python
must be at the top of the file - What is
sys import argv
- What is
script, filename = argv
- Is
.read()
a built in function?