Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Whip me. Beat me. Make me maintain AIX." (By Stephan Zielinski)


devel / comp.lang.python / Re: tail

SubjectAuthor
o Re: tailCameron Simpson

1
Re: tail

<mailman.359.1652075709.20749.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18202&group=comp.lang.python#18202

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Mon, 9 May 2022 15:14:16 +1000
Lines: 41
Message-ID: <mailman.359.1652075709.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de mOuaQELnfipaJjMcnNKwYw7d9P8sd89Kn9xlkS+b2crQ==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.006
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'stream': 0.04; '2022':
0.05; 'absolute': 0.05; 'variable': 0.05; 'sun,': 0.07; 'thing.':
0.07; 'byte': 0.09; 'deeper': 0.09; 'ended': 0.09; 'cheers,':
0.11; 'arbitrary': 0.16; 'barry': 0.16; 'behaviour': 0.16;
'cameron': 0.16; 'characters.': 0.16; 'criteria:': 0.16;
'encoding': 0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au':
0.16; 'from:name:cameron simpson': 0.16; 'inspect': 0.16;
'message-id:@cskk.homeip.net': 0.16; 'received:10.10': 0.16;
'simpson': 0.16; 'skip:> 10': 0.16; 'stream.': 0.16; 'url:seek':
0.16; 'wrote:': 0.16; 'says': 0.17; 'to:addr:python-list': 0.20;
'cannot': 0.25; 'binary': 0.26; 'header:User-Agent:1': 0.30;
'but': 0.32; 'there': 0.33; 'mean': 0.34; 'header:In-Reply-To:1':
0.34; 'meaning': 0.35; 'files': 0.36; 'file': 0.38; 'means': 0.38;
'adding': 0.39; 'text': 0.39; 'otherwise': 0.39; 'on.': 0.39;
'should': 0.40; 'basis': 0.62; 'mode': 0.62; 'here': 0.62;
'between': 0.63; 'down': 0.64; 'with:': 0.64; 'well': 0.65;
'received:userid': 0.66; 'header:Received:6': 0.67; 'further':
0.69; 'compare': 0.69; 'knowing': 0.71; 'low': 0.74; 'produces':
0.76; 'returned': 0.81; 'seek': 0.81; 'position': 0.81;
'backwards': 0.84; 'characters': 0.84; 'sulla': 0.84; 'mode.':
0.89; 'positions': 0.96
X-RG-Spam: Unknown
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekgdelgecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfupfevtfgpvffgnffuvffttedpqfgfvfenuceurghilhhouhhtmecugedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhepfffhvffukfggtggugfgjfghfsehtkeertddtreejnecuhfhrohhmpeevrghmvghrohhnucfuihhmphhsohhnuceotghssegtshhkkhdrihgurdgruheqnecuggftrfgrthhtvghrnhepkeeuleetgfehueeutdevudfgheeuveffffduvddvudefiefhffffvdeftdfgfffgnecuffhomhgrihhnpehphihthhhonhdrohhrghdpihhosggrshgvrdhsvggvkhdpthgvgihtihhosggrshgvrdhsvggvkhenucfkphepuddrudeghedrgeehrddujedtnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghlohepsghorhhgrdgtshhkkhdrhhhomhgvihhprdhnvghtpdhinhgvthepuddrudeghedrgeehrddujedtpdhmrghilhhfrhhomheptggrmhgvrhhonhestghskhhkrdhiugdrrghupdhnsggprhgtphhtthhopedupdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhg
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-RG-VS-CLASS: clean
X-Authentication-Info: Submitted using ID cskk@bigpond.com
Mail-Followup-To: Python List <python-list@python.org>
Content-Disposition: inline
In-Reply-To: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
User-Agent: Mutt/2.2.3 (2022-04-12)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <YnijKH0NJdtDd2sa@cskk.homeip.net>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
 by: Cameron Simpson - Mon, 9 May 2022 05:14 UTC

On 08May2022 22:48, Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
>On Sun, 8 May 2022 at 22:34, Barry <barry@barrys-emacs.org> wrote:
>> >> In text mode you can only seek to a value return from f.tell()
>> >> otherwise the behaviour is undefined.
>> >
>> > Why? I don't see any recommendation about it in the docs:
>> > https://docs.python.org/3/library/io.html#io.IOBase.seek
>>
>> What does adding 1 to a pos mean?
>> If it’s binary it mean 1 byte further down the file but in text mode it may need to
>> move the point 1, 2 or 3 bytes down the file.
>
>Emh. I re-quote
>
>seek(offset, whence=SEEK_SET)
>Change the stream position to the given byte offset.
>
>And so on. No mention of differences between text and binary mode.

You're looking at IOBase, the _binary_ basis of low level common file
I/O. Compare with: https://docs.python.org/3/library/io.html#io.TextIOBase.seek
The positions are "opaque numbers", which means you should not ascribe
any deeper meaning to them except that they represent a point in the
file. It clearly says "offset must either be a number returned by
TextIOBase.tell(), or zero. Any other offset value produces undefined
behaviour."

The point here is that text is a very different thing. Because you
cannot seek to an absolute number of characters in an encoding with
variable sized characters. _If_ you did a seek to an arbitrary number
you can end up in the middle of some character. And there are encodings
where you cannot inspect the data to find a character boundary in the
byte stream.

Reading text files backwards is not a well defined thing without
additional criteria:
- knowing the text file actually ended on a character boundary
- knowing how to find a character boundary

Cheers,
Cameron Simpson <cs@cskk.id.au>

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor