Alex Martelli
2001-04-29 21:38:18 UTC
"Harald Kirsch" <kirschh at lionbioscience.com> wrote in message
news:yv2y9sm469d.fsf at lionsp093.lion-ag.de...
[snip]
less straighforward, as your example code demonstrates.
This is not a formally documented constraint on the parser (alas,
until and unless interfaces or protocols do get formalized in Python,
we'll have to live with lots of informal mentions of [e.g.] "file-like
objects" that never clarify WHICH file-object methods do need to
be implemented...), but for the current implementation it can be
determined experimentally. Code inspection on the library sources
AND running a few experiments on an instrumented filelike object
(that delegates all to a file but also prints out what is being called)
to confirm one's understanding gives you that with a few minutes'
investment.
Alex
news:yv2y9sm469d.fsf at lionsp093.lion-ag.de...
[snip]
Fortunately, the parser just calls .read(N) on its
*That* was the information I was missing. The rest is then more orless straighforward, as your example code demonstrates.
until and unless interfaces or protocols do get formalized in Python,
we'll have to live with lots of informal mentions of [e.g.] "file-like
objects" that never clarify WHICH file-object methods do need to
be implemented...), but for the current implementation it can be
determined experimentally. Code inspection on the library sources
AND running a few experiments on an instrumented filelike object
(that delegates all to a file but also prints out what is being called)
to confirm one's understanding gives you that with a few minutes'
investment.
Alex