While going through the exercises, I came across something that, even after research, I simply cannot grasp.
Here’s the specific bit of code:
def print_all(f):
print f.read()
For the whole script: http://learnpythonthehardway.org/book/ex20.html
What’s really, really confusing me is the (f) part.
Where does that f come from? What’s its purpose?
Oh well, thanks in advance!
fis an argument to the function, it is expected to be a file like object and is constructed with an open call in the example provided.where
argv(provided by thesysmodule) is the list of strings provided on the commandline e.g.["ex20.py", "test.txt"]