On Fri, 27 May 2022 at 12:01, Stephen J. Turnbull
<stephenjturnb...@gmail.com> wrote:
>
> Chris Angelico writes:
>
>  > If I'm reading this correctly, the result from f.tell() has enough
>  > information to reconstruct a position within a hypothetical array
>  > of code points contained within the file (that is to say - if you
>  > read the entire file into a string, f.tell() returns something that
>  > can be turned into an index into that string), but that position
>  > might not actually correspond to a single byte location. Is that it?
>
> That's what the OP wants.  That's not what f.tell does.  f.tell
> returns information sufficient to recreate the state of the stream I/O
> part of a codec when it reaches that point in the stream.  Its
> *purpose* is to support producing the rest of the str produced by
> f.read() after a shorter read, but f.tell doesn't care if the str ever
> existed or ever will exist in the process that calls it.
>

Well, the OP wants to be able to do arithmetic on it, but what
actually happens is that it's nothing more than a magic cookie.

But it ought to be able to recreate the state at any point, after
returning any number of characters. Right? There's no way that it
would ever fail to get to the same position in a character stream.
It's just that there's no way to synthesize that, you have to start at
the beginning.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EJWD7E5RJKWDCDDANF5ZOR3U3XP2VIX7/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to