From 3b522de2d686b802e2ee8690d9007a96f20897b6 Mon Sep 17 00:00:00 2001 From: wirawan Date: Wed, 31 Aug 2011 20:28:30 +0000 Subject: [PATCH] * Added text_input.close() method. --- iofmt/text_input.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/iofmt/text_input.py b/iofmt/text_input.py index 9b969d3..fd979d4 100644 --- a/iofmt/text_input.py +++ b/iofmt/text_input.py @@ -1,5 +1,5 @@ #!/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 # Quick-n-dirty text input utilities @@ -28,7 +28,7 @@ import re import numpy 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): '''Text input reader with support for UNIX-style comment marker (#) and @@ -62,6 +62,11 @@ class text_input(object): if getattr(self, "file", None): self.file.close() + def close(self): + if getattr(self, "file", None): + self.file.close() + del self.file + def __iter__(self): return self