* Added text_input.close() method.

master
wirawan 13 years ago
parent 7d37c0b6ba
commit 3b522de2d6
  1. 9
      iofmt/text_input.py

@ -1,5 +1,5 @@
#!/usr/bin/python #!/usr/bin/python
# $Id: text_input.py,v 1.3 2011-06-03 21:34:32 wirawan Exp $ # $Id: text_input.py,v 1.4 2011-08-31 20:28:30 wirawan Exp $
# #
# wpylib.iofmt.text_input module # wpylib.iofmt.text_input module
# Quick-n-dirty text input utilities # Quick-n-dirty text input utilities
@ -28,7 +28,7 @@ import re
import numpy import numpy
from wpylib.file.file_utils import open_input_file from wpylib.file.file_utils import open_input_file
from wpylib.hacks import make_unbound_instance_method from wpylib.py import make_unbound_instance_method
class text_input(object): class text_input(object):
'''Text input reader with support for UNIX-style comment marker (#) and '''Text input reader with support for UNIX-style comment marker (#) and
@ -62,6 +62,11 @@ class text_input(object):
if getattr(self, "file", None): if getattr(self, "file", None):
self.file.close() self.file.close()
def close(self):
if getattr(self, "file", None):
self.file.close()
del self.file
def __iter__(self): def __iter__(self):
return self return self

Loading…
Cancel
Save