At 01:08 AM 6/3/2005 +1000, Nick Coghlan wrote: >Also, I'm wondering if it would be useful to have a 'closing' template >that looked like: > > @with_template > def closing(obj): > try: > yield obj > finally: > obj.close()
+1 if you make it 'if hasattr(obj,"close"): obj.close()' in the finally clause, so that it will still work if the type of the object changes. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com