Message77376
Seems like file.close() in 3.0 isn't much of a barrier to further reading:
% python3.0
Python 3.0rc3+ (py3k:67338M, Nov 22 2008, 06:47:23)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> fp = open("/etc/services")
>>> ct = fp.read(1048)
>>> print (ct[-80:], end='') ; fp.close() ; ct = fp.read(17) ; print (ct)
compressnet 2/udp # Management Utility
compressnet 2/tcp # Management Utility
The second read() should raise an exception. Same code, 2.6:
% python2.6
Python 2.6+ (release26-maint:66821:66833, Oct 30 2008, 22:16:1)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> fp = open("/etc/services")
>>> ct = fp.read(1048)
>>> print (ct[-80:], end='') ; fp.close() ; ct = fp.read(17) ; print (ct)
compressnet 2/udp # Management Utility
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: I/O operation on closed file
compressnet 2/tcp # M>>>
Culled this from a posting to comp.lang.python. |
|
Date |
User |
Action |
Args |
2008-12-09 00:11:21 | skip.montanaro | set | recipients:
+ skip.montanaro |
2008-12-09 00:11:21 | skip.montanaro | set | messageid: <1228781481.66.0.10678075439.issue4604@psf.upfronthosting.co.za> |
2008-12-09 00:11:20 | skip.montanaro | link | issue4604 messages |
2008-12-09 00:11:19 | skip.montanaro | create | |
|