[Python-Dev] pre-PEP: Resource-Release Support for Generators
Neil Schemenauer
nas-python at python.ca
Tue Aug 26 07:49:01 EDT 2003
More information about the Python-Dev mailing list
Tue Aug 26 07:49:01 EDT 2003
- Previous message: [Python-Dev] pre-PEP: Resource-Release Support for Generators
- Next message: [Python-Dev] pre-PEP: Resource-Release Support for Generators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Samuele Pedroni wrote:
> This PEP proposes that generators should grow such a close method
> with such semantics that the example could be rewritten as:
>
> def all_lines(index_path):
> index = file(index_path,"r")
> try:
> for path in file(index_path,"r"):
^^^^^^^^^^^^^^^^^^^^
> document = file(path.strip(),"r")
> try:
> for line in document:
> yield line
> finally:
> document.close()
> finally:
> index.close()
I think that should be 'index'.
Neil
- Previous message: [Python-Dev] pre-PEP: Resource-Release Support for Generators
- Next message: [Python-Dev] pre-PEP: Resource-Release Support for Generators
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list