Python vs Java garbage collection?
Erik Max Francis
max at alcyone.com
Mon Dec 23 04:47:45 EST 2002
More information about the Python-list mailing list
Mon Dec 23 04:47:45 EST 2002
- Previous message (by thread): Python vs Java garbage collection?
- Next message (by thread): Python vs Java garbage collection?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Ype Kingma wrote: > Untested code: > > def openread(fname): > try: > fp = open(fname) > return fp.read() > finally: > fp.close() > > Python has enough syntax already. Really this should be: fp = open(fname) try: return fp.read() finally: fp.close() If open throws, then the fp name will not be bound, so on the way out the finally clause will generate a NameError. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE / \ There is nothing so subject to the inconstancy of fortune as war. \__/ Miguel de Cervantes EmPy / http://www.alcyone.com/pyos/empy/ A templating system for Python.
- Previous message (by thread): Python vs Java garbage collection?
- Next message (by thread): Python vs Java garbage collection?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list