Is it necessary to use ‘as’ while opening a file?
I have the same question
Yes, it is part of the signature line since our local file object needs an identifier. We can alias the file name to a simple form which makes things easier.
>>> with open('workfile') as f:
(from the example at reading-and-writing-files)