osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File not closed


Hello

In the following snippet, a file is opened but
without any variable referring to it.
So the file can't be closed.

[line.split(":")[0]
  for line in open('/etc/passwd')
  if line.strip() and not line.startswith("#")]

What do you think about this practice ?