[Python-3000] iostack, second revision
talin at acm.org
Fri Sep 8 19:12:13 CEST 2006
Nick Coghlan wrote:
> Guido van Rossum wrote:
>> Maybe (since I fall in that category it doesn't bother me :-), but we
>> shouldn't replace them with symbolic constants. Having to import
>> another module to import names like SEEK_CUR and SEEK_END is not
>> Pythonic. Perhaps the seek() method can grow keyword arguments to
>> indicate the different types of seekage, or there should be three
>> separate methods.
> As I mentioned in a different part of the thread, I believe seek(), seekby()
> and rseek() would work as names for the 3 different method approach.
One advantage of that approach is that layers which don't support a
particular operation could omit one or more of those functions, or have
differently-named functions that represent what the layer is capable of.
For example, if a layer is only capable of seeking forward, you could
use 'skip' like the Java stream does; If a layer can rewind the stream
back to zero, but not to any intermediate position, you could have a
By taking this approach, you can come up with an API for a given layer
that fits naturally into the behavior model of that layer, without
trying to cram it into a generic model for seeking that attempts to
cover all cases. For text streams, come up with a model that makes sense
for what kinds of things you want to do with text, and don't try and
make it look like the API for the underlying byte stream.
More information about the Python-3000