Does the following syntax close the file:
lines = [line.strip() for line in open(\'/somefile/somewhere\')]
Bonus points if you can demonstr
This is how you should do it
with open('/somefile/somewhere') as f:
lines = [line.strip() for line in f]
In CPython the file should be closed right away as there are no references to it left, but Python language does not guarantee this.
In Jython, the file won't be closed until the garbage collector runs