Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I've seen it. It's rubbish." -- Marvin the Paranoid Android


devel / comp.lang.python / Re: tail

SubjectAuthor
* Re: tailMarco Sulla
+* Re: tailDennis Lee Bieber
|+* Re: tailMarco Sulla
||`- Re: tailStefan Ram
|+* Re: tailChris Angelico
||`* Re: tailDennis Lee Bieber
|| `- Re: tailAvi Gross
|+- Re: tailMarco Sulla
|+- Re: tailChris Angelico
|+- Re: tailAvi Gross
|`* Re: tailMarco Sulla
| `* Re: tailStefan Ram
|  `* Re: tailMarco Sulla
|   `- Re: tailDennis Lee Bieber
`- Re: tailAlan Bawden

1
Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Mon, 9 May 2022 21:11:23 +0200
Lines: 27
Message-ID: <mailman.363.1652123522.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de HLafsyC+qvrSyGMLwDy/mw4c9gTkcYdGUHnX9Y7bwKFw==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=FEKWa0kt;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.001
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2022': 0.05; 'absolute':
0.05; 'variable': 0.05; 'thing.': 0.07; 'angelico': 0.09;
'anyway,': 0.09; 'byte': 0.09; 'cc:addr:python-list': 0.09;
'fundamental': 0.09; 'language,': 0.09; 'arbitrary': 0.16;
'barry': 0.16; 'cameron': 0.16; 'cc:name:python list': 0.16;
'characters.': 0.16; 'encoding': 0.16; 'from:name:marco sulla':
0.16; 'impossible': 0.16; 'inspect': 0.16; 'mean.': 0.16;
'reliable,': 0.16; 'simpson': 0.16; 'stdlib': 0.16; 'stream.':
0.16; 'toolkit.': 0.16; 'wrote:': 0.16; "can't": 0.17; 'solve':
0.19; 'tue,': 0.19; 'cc:addr:python.org': 0.20; 'code': 0.23;
'command': 0.23; 'cannot': 0.25; 'cc:2**0': 0.25; 'binary': 0.26;
'function': 0.27; 'chris': 0.28; 'received:209.85.160': 0.31;
"doesn't": 0.32; 'do.': 0.32; 'message-id:@mail.gmail.com': 0.32;
'but': 0.32; 'there': 0.33; 'core': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'files': 0.36; 'mon,': 0.36; "it's": 0.37; 'received:209.85':
0.37; 'file': 0.38; 'way': 0.38; 'means': 0.38; 'received:209':
0.39; 'text': 0.39; 'handle': 0.39; 'still': 0.40; 'best': 0.61;
"there's": 0.61; 'mode': 0.62; 'here': 0.62; 'your': 0.64; 'tool':
0.65; 'worked': 0.67; 'reliable': 0.74; 'mode,': 0.76; 'seek':
0.81; 'characters': 0.84; 'decent': 0.84; 'performance.': 0.84;
'sulla': 0.84; 'reliable.': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=wJviHpcfiRFO6lBIFqwwNkU68svv9dsojR/JTM9HBk0=;
b=FEKWa0ktzfnMAyNDEuTCx0AyHCzotFp0Ay9bO3oeIyqMF2HaPzFLiuFfAjJFkbvl8y
lJLQ7jpf4zUoV5V3LH/1acFYEKTVNmNwZhq5/FFNzExHWMqt3LbnMMi7+kkVfd/xBic3
fvm9VwQdDBc2eszq6JdCOtrCKRsS8hLOvPcZwbDy+4d0GlBTIeo1eBPf/HC9TzVxKeXZ
eVo3Jbhwg3bMqZXLB+SVzZgjr5BBghereYYpyqy+JkMOA64aXCdzZCxGKZoWRr9tViUl
oC2o5COsRPsM1EvkwipHJj/80u86uU290XNnutnu9g2sXuzSSucoUdy0HNd1jKSXD/O+
j4Aw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=wJviHpcfiRFO6lBIFqwwNkU68svv9dsojR/JTM9HBk0=;
b=CVOQH1xTMWKBV0QVfqNzx6Iv91BbaAZqZvsCaeBNdQIvfxf/V2GnIAGAHOpT8YMgEl
3BYeK06vMdww0cnbSsG1QFp7N9mk74L7jkkIdSOQHRvhBXp8QKGR0jR/L/xD9G/JYG+d
wm//cxazxsskZgOyPr8Nyx2RN+GEw/GOamEdjOlPoBh8joZkjZHYrpsYWIKV2Z9k8KyY
hV38hI8Xzg3/WkyZhbPQkkWGT3KyEALeTtiP7kMKpUHEc+XZYXAskUS5nV+EedAWzdKq
A6irnQ3QUPu/pCi4vPB9PAwvCBSPbhdS2mjdY9RDykIZBsfmg6llkNQVCTFLVx8tKzAr
4f7Q==
X-Gm-Message-State: AOAM531Z8Uff7PDyXBndZMrMgBXBNyX4o+f6WrORPCwIeMbcJ3eilAbx
LC6Z4BT8HaS1Ot+8bQOHBnNThdJSIxon33eigM8=
X-Google-Smtp-Source: ABdhPJwiTXeraftfpJ+QB85fIr54vy0Keys+07CM0ry5yjgRp8qwZS41H7HYtl5QjIhv1YOgCItvdxZYSDUxSiA2shs=
X-Received: by 2002:a05:6870:b3a4:b0:e9:2370:5e9 with SMTP id
w36-20020a056870b3a400b000e9237005e9mr11378185oap.73.1652123520026; Mon, 09
May 2022 12:12:00 -0700 (PDT)
In-Reply-To: <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
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: <CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
 by: Marco Sulla - Mon, 9 May 2022 19:11 UTC

On Mon, 9 May 2022 at 19:53, Chris Angelico <rosuav@gmail.com> wrote:
>
> On Tue, 10 May 2022 at 03:47, Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
> >
> > On Mon, 9 May 2022 at 07:56, Cameron Simpson <cs@cskk.id.au> wrote:
> > >
> > > 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.
> >
> > Ooook, now I understand what you and Barry mean. I suppose there's no
> > reliable way to tail a big file opened in text mode with a decent performance.
> >
> > Anyway, the previous-previous function I posted worked only for files
> > opened in binary mode, and I suppose it's reliable, since it searches
> > only for b"\n", as readline() in binary mode do.
>
> It's still fundamentally impossible to solve this in a general way, so
> the best way to do things will always be to code for *your* specific
> use-case. That means that this doesn't belong in the stdlib or core
> language, but in your own toolkit.

Nevertheless, tail is a fundamental tool in *nix. It's fast and
reliable. Also the tail command can't handle different encodings?

Re: tail

<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 09 May 2022 16:05:46 -0500
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Mon, 09 May 2022 17:05:46 -0400
Organization: IISS Elusive Unicorn
Message-ID: <dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com> <YnijKH0NJdtDd2sa@cskk.homeip.net> <CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com> <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com> <CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com> <mailman.363.1652123522.20749.python-list@python.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 24
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-aE91kp92JNUhVWoOR+8Qxubgd0ouiXIeEPjhFLn9DvQI5OgTDRpr/7Nz5S1sUubGKi4DAFnHUetnEwh!wKmEdQWyRXY5YxUkjPt05vAoenbsrNUjhvqVsPzPPjrGm++nK4RgpZw25cKXulxjkFUhg/Pl
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2522
 by: Dennis Lee Bieber - Mon, 9 May 2022 21:05 UTC

On Mon, 9 May 2022 21:11:23 +0200, Marco Sulla
<Marco.Sulla.Python@gmail.com> declaimed the following:

>Nevertheless, tail is a fundamental tool in *nix. It's fast and
>reliable. Also the tail command can't handle different encodings?

Based upon
https://github.com/coreutils/coreutils/blob/master/src/tail.c the ONLY
thing tail looks at is single byte "\n". It does not handle other line
endings, and appears to performs BINARY I/O, not text I/O. It does nothing
for bytes that are not "\n". Split multi-byte encodings are irrelevant
since, if it does not find enough "\n" bytes in the buffer (chunk) it reads
another binary chunk and seeks for additional "\n" bytes. Once it finds the
desired amount, it is synchronized on the byte following the "\n" (which,
for multi-byte encodings might be a NUL, but in any event, should be a safe
location for subsequent I/O).

Interpretation of encoding appears to fall to the console driver
configuration when displaying the bytes output by tail.

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: tail

<86y1zatmti.fsf@williamsburg.bawden.org>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ala...@csail.mit.edu (Alan Bawden)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Mon, 09 May 2022 17:31:37 -0400
Organization: ITS Preservation Society
Lines: 13
Message-ID: <86y1zatmti.fsf@williamsburg.bawden.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4adce975ca97c3e3e3ac9efbd2cd8e0d";
logging-data="2329"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ovvv2SigzUev3v3SwvYa7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock: sha1:Qatr58ISB+wybpkYwiHKmoAjYCU=
sha1:owJwCWvXFSO44vuATbpRP6Ok1Fc=
 by: Alan Bawden - Mon, 9 May 2022 21:31 UTC

Marco Sulla <Marco.Sulla.Python@gmail.com> writes:

On Mon, 9 May 2022 at 19:53, Chris Angelico <rosuav@gmail.com> wrote:
...
Nevertheless, tail is a fundamental tool in *nix. It's fast and
reliable. Also the tail command can't handle different encodings?

It definitely can't. It works for UTF-8, and all the ASCII compatible
single byte encodings, but feed it a file encoded in UTF-16, and it will
sometimes screw up. (And if you don't redirect the output away from
your terminal, and your terminal encoding isn't also set to UTF-16, you
will likely find yourself looking at gibberish -- but that's another
problem...)

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Wed, 11 May 2022 21:58:13 +0200
Lines: 106
Message-ID: <mailman.375.1652299133.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de RaiPZBbC01lybodSZXSojw+3S3eFamo/IQSpaCBnNbUw==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=hOWh+LVM;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'looks': 0.02; 'url-
ip:140.82/16': 0.03; 'def': 0.04; '2022': 0.05; '(to': 0.07;
'simple.': 0.07; 'string': 0.07; 'byte': 0.09; 'cc:addr:python-
list': 0.09; 'fundamental': 0.09; 'ok,': 0.09; 'url:master': 0.09;
'&gt;': 0.14; 'cc:no real name:2**0': 0.14; 'url:github': 0.14;
'import': 0.15; 'url-ip:140/8': 0.15; '"\\n"': 0.16; '&lt;': 0.16;
'*nix': 0.16; '+0200,': 0.16; '-1:': 0.16; 'cpython': 0.16;
'encoding': 0.16; 'from:name:marco sulla': 0.16; 'integer': 0.16;
'number"': 0.16; 'passed.': 0.16; 'seeks': 0.16; 'skip:> 10':
0.16; 'understand.': 0.16; 'wrote:': 0.16; 'python': 0.16;
"can't": 0.17; 'it?': 0.19; 'cc:addr:python.org': 0.20; 'written':
0.22; 'returns': 0.22; 'skip:_ 10': 0.22; 'command': 0.23;
'lines': 0.23; "i'd": 0.24; '(and': 0.25; 'cc:2**0': 0.25;
'seems': 0.26; 'binary': 0.26; 'object': 0.26; 'function': 0.27;
'chris': 0.28; 'output': 0.28; 'received:209.85.210': 0.29;
'raise': 0.31; 'think': 0.32; 'do.': 0.32; 'split': 0.32;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'following': 0.35;
'final': 0.35; 'from:addr:gmail.com': 0.35; 'mon,': 0.36; 'using':
0.37; "it's": 0.37; 'received:209.85': 0.37; 'file': 0.38;
'could': 0.38; 'read': 0.38; 'received:209': 0.39; 'quite': 0.39;
'single': 0.39; 'text': 0.39; 'enough': 0.39; 'handle': 0.39;
'safe': 0.39; 'use': 0.39; 'break': 0.39; 'appears': 0.40;
'consistent': 0.40; 'should': 0.40; 'method': 0.61; 'skip:b 30':
0.61; 'skip:o 10': 0.61; 'mode': 0.62; 'skip:o 20': 0.63; 'once':
0.63; 'skip:b 10': 0.63; 'upon': 0.64; 'tool': 0.65; 'url:c':
0.66; 'end,': 0.69; 'following:': 0.69; 'stores': 0.69; 'skip:f
20': 0.75; 'finds': 0.76; 'mode,': 0.76; 'subsequent': 0.76;
'amount,': 0.84; 'converted': 0.84; 'driver': 0.84; 'sulla': 0.84;
'url:src': 0.84; 'positive': 0.86; 'mode.': 0.89; 'reliable.':
0.91; 'performs': 0.93; 'fall': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=BKTjf//co1/gS3W+w1/iAP1r8IzlmrGSvtHoKQcbXrQ=;
b=hOWh+LVMYbjBepAD2ZOz+RkTe/j03rV728NQuCbPBcqAu1cSGaXoG2v3/WSNLnnHYl
OAcu5WEvJWKnjThoYJyNNnalFtVQdHM+H6Kl9lo/pbLPa2qd7gTYZX+ePn7t7oRkEkMU
/vv2W5HOD5RXKOCyFVboOFGW0nxmHW2YUDOprijm45DUiBx4bSQF9tPe9BDEidkyPfZO
FIWKBJ+d8I9sxgniwv2/8ULVQhW3yWMDh6UvRenMpfO8Gr7hc/KtNyHSkH4QdkGDKe/s
ni6terlr8OQOyp4v7/Utzo2K9Ll30HS38LOmZSUP8qd48v2cHPQ51P0vr70QcZju+SeE
ADnA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=BKTjf//co1/gS3W+w1/iAP1r8IzlmrGSvtHoKQcbXrQ=;
b=kABCywjfIckb9cZgwQPgzf+thw64F388oeE7U9M5dob27soBTAsRDFLp/G2JOvdjMD
081t0P9CnedUAJ5wn19ycQ1hTDKOX4vXA4GclZ6bb+LsXzdXvqmZNOsSpPDrLlTkBoU1
4H/uOxuJ2xlUTnlr1kiLlvEuaY5hk9eCK+QsiN5WryReyJp0Zn44ljm9v+9Liy8oMKzX
9uu2FRyo6C4YTz2x302hptLxuUO87xijb85gTX/ca9ZYCMHVvLvDog6Cn6zFgY3nFtd2
AuQ6lWva6WEyC6r7v3cAOOdDA2YTbAp8h/lEx3OSjgWlGs6rUb7haVNmKMZ7KS4Dlp0F
OX/Q==
X-Gm-Message-State: AOAM5303llx1jzW7atjzmDuLv75v+Yd9w2GFFFr//cdEOFUF59r9HlY8
Aj+tY+KrP1P8HJOvcKTd4avEqAvvGsm/WhfMNLBtW+tRODI=
X-Google-Smtp-Source: ABdhPJySSOuKeNve5JQ3j5If4XctW6mMSvgEqgDb9o9gcOirGx1vUgziYkOJ0FoDB1jpwJMCHwivpl2Et0Fp/XhV2Ck=
X-Received: by 2002:a9d:7399:0:b0:606:d374:9268 with SMTP id
j25-20020a9d7399000000b00606d3749268mr440419otk.247.1652299130678; Wed, 11
May 2022 12:58:50 -0700 (PDT)
In-Reply-To: <dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
 by: Marco Sulla - Wed, 11 May 2022 19:58 UTC

On Mon, 9 May 2022 at 23:15, Dennis Lee Bieber <wlfraed@ix.netcom.com>
wrote:
>
> On Mon, 9 May 2022 21:11:23 +0200, Marco Sulla
> <Marco.Sulla.Python@gmail.com> declaimed the following:
>
> >Nevertheless, tail is a fundamental tool in *nix. It's fast and
> >reliable. Also the tail command can't handle different encodings?
>
> Based upon
> https://github.com/coreutils/coreutils/blob/master/src/tail.c the ONLY
> thing tail looks at is single byte "\n". It does not handle other line
> endings, and appears to performs BINARY I/O, not text I/O. It does nothing
> for bytes that are not "\n". Split multi-byte encodings are irrelevant
> since, if it does not find enough "\n" bytes in the buffer (chunk) it
reads
> another binary chunk and seeks for additional "\n" bytes. Once it finds
the
> desired amount, it is synchronized on the byte following the "\n" (which,
> for multi-byte encodings might be a NUL, but in any event, should be a
safe
> location for subsequent I/O).
>
> Interpretation of encoding appears to fall to the console driver
> configuration when displaying the bytes output by tail.

Ok, I understand. This should be a Python implementation of *nix tail:

import os

_lf = b"\n"
_err_n = "Parameter n must be a positive integer number"
_err_chunk_size = "Parameter chunk_size must be a positive integer number"

def tail(filepath, n=10, chunk_size=100):
if (n <= 0):
raise ValueError(_err_n)

if (n % 1 != 0):
raise ValueError(_err_n)

if (chunk_size <= 0):
raise ValueError(_err_chunk_size)

if (chunk_size % 1 != 0):
raise ValueError(_err_chunk_size)

n_chunk_size = n * chunk_size
pos = os.stat(filepath).st_size
chunk_line_pos = -1
lines_not_found = n

with open(filepath, "rb") as f:
text = bytearray()

while pos != 0:
pos -= n_chunk_size

if pos < 0:
pos = 0

f.seek(pos)
chars = f.read(n_chunk_size)
text[0:0] = chars
search_pos = n_chunk_size

while search_pos != -1:
chunk_line_pos = chars.rfind(_lf, 0, search_pos)

if chunk_line_pos != -1:
lines_not_found -= 1

if lines_not_found == 0:
break

search_pos = chunk_line_pos

if lines_not_found == 0:
break

return bytes(text[chunk_line_pos+1:])

The function opens the file in binary mode and searches only for b"\n". It
returns the last n lines of the file as bytes.

I suppose this function is fast. It reads the bytes from the file in chunks
and stores them in a bytearray, prepending them to it. The final result is
read from the bytearray and converted to bytes (to be consistent with the
read method).

I suppose the function is reliable. File is opened in binary mode and only
b"\n" is searched as line end, as *nix tail (and python readline in binary
mode) do. And bytes are returned. The caller can use them as is or convert
them to a string using the encoding it wants, or do whatever its
imagination can think :)

Finally, it seems to me the function is quite simple.

If all my affirmations are true, the three obstacles written by Chris
should be passed.

I'd very much like to see a CPython implementation of that function. It
could be a method of a file object opened in binary mode, and *only* in
binary mode.

What do you think about it?

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 06:07:18 +1000
Lines: 36
Message-ID: <mailman.376.1652299651.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de MkGc6Ui+K5YaI+ty9fdWcA9ivp4b6q7vy3NheiZ0pvvg==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=JeQxd894;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.012
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'library.':
0.05; '(to': 0.07; 'simple.': 0.07; 'string': 0.07; 'general,':
0.09; '*nix': 0.16; 'along.': 0.16; 'assumptions': 0.16; 'chrisa':
0.16; 'cpython': 0.16; 'else?': 0.16; 'encoding': 0.16;
'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'language?': 0.16; 'passed.': 0.16; 'toolkit.': 0.16; 'wrote:':
0.16; 'python': 0.16; 'code.': 0.17; 'it?': 0.19; 'thu,': 0.19;
'to:addr:python-list': 0.20; 'written': 0.22; "i've": 0.22; "i'd":
0.24; '(and': 0.25; 'saying': 0.25; 'anyone': 0.25; 'seems': 0.26;
'binary': 0.26; 'object': 0.26; "isn't": 0.27; 'function': 0.27;
'chris': 0.28; 'think': 0.32; 'assume': 0.32; 'do.': 0.32;
'message-id:@mail.gmail.com': 0.32; 'same': 0.34; 'core': 0.34;
'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'final': 0.35; 'from:addr:gmail.com': 0.35; 'people': 0.36;
'those': 0.36; 'using': 0.37; 'received:209.85': 0.37; 'file':
0.38; 'could': 0.38; 'read': 0.38; 'received:209': 0.39; 'quite':
0.39; 'use': 0.39; 'still': 0.40; 'consistent': 0.40; 'wants':
0.40; 'should': 0.40; 'method': 0.61; 'mode': 0.62; 'simply':
0.63; 'your': 0.64; 'benefit': 0.65; 'well': 0.65; 'end,': 0.69;
'stores': 0.69; 'mode,': 0.76; 'need,': 0.76; 'converted': 0.84;
'merely': 0.84; 'sulla': 0.84; 'three,': 0.84; 'mode.': 0.89;
'reliable.': 0.91; 'safely': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=z291HIo1Ap5MqLCGRGqpLVSx+HZoW0x3sXxFvPdrVxA=;
b=JeQxd894LdTKbmE4v9eO/Tf/8fCgHp1eIzWpXpT/I+Kztp6GnKVVad4vKHyWOsztb8
QWgfrGrpqJAjKGkjeIW9JwP10+egDk5LEYX6rq/EfHTquLnWOrW5d7l9w7+9LBWU4Bx/
vv9oI0cf6JoG9ZuAyzMBipEqMHnh3/F9EeJTTcSXSiciD3ut0DWKOZkNtUAnbYHZHi+7
BMwfoHIAWjHAE+4wD8wUoJB+vVBnsLlTDekSZo1nk3WNjLHMCi5S+v5W2TvQ29HVIiD9
zvQ1D4nfMjmYTkhtYJbWgffBOuXsL1uRK/SKD5weWTniPHFYWot2mLnuqCgqOZ+qTEXK
oEqg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=z291HIo1Ap5MqLCGRGqpLVSx+HZoW0x3sXxFvPdrVxA=;
b=tTa5jEB1gvi8oaPSZvUvDGG8VdzzzhxFnFmv4YZk5M4qW+EiDDiOmvh2+dhiImFEtG
4TgTATAF2ZG3eylTJFsB3gvw22Gabmjviw2eeBEnwdyKQW3IVmwVvOll4C7pJJhFc9hN
KVFIJBTk3Z0X/6Ia2PpKAsKP4y4X2MF8T866H8DKfbwHQM7dPgat8dqWvs/1H80dMD0D
o5dr4MFzFVF2LdKg1iFlD+mSuy1ixrWJCSwMTh+/d5xJa+nFt6KPmE+H65gDZzsUPzqb
Ekbdq2yobxfFIvC1kLk4pszabqPib/xQbRCup2mTMJxnfULu8gbQV4DEjpYUkuIsLSF+
rZVA==
X-Gm-Message-State: AOAM530SXE1fb+1yWdlFNt25nQpeXiTyQjNZgB0Ql/I+u3LdDLUIEZAW
NWOIa/BE6qtBkz4wI1nSix2Sl/4E8Vx9tf7G93+B7Rkb
X-Google-Smtp-Source: ABdhPJzzeKHk2M0G4DE5d4wH3ksb2P5bcBmoFZBLBXu4O08sdlvKYpYuZd/uGBoC72AV1cPWE9oiqm81xmMsajT5L6I=
X-Received: by 2002:a5d:68c6:0:b0:20a:d654:6cae with SMTP id
p6-20020a5d68c6000000b0020ad6546caemr23515623wrw.564.1652299649702; Wed, 11
May 2022 13:07:29 -0700 (PDT)
In-Reply-To: <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
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: <CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
 by: Chris Angelico - Wed, 11 May 2022 20:07 UTC

On Thu, 12 May 2022 at 06:03, Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
> I suppose this function is fast. It reads the bytes from the file in chunks
> and stores them in a bytearray, prepending them to it. The final result is
> read from the bytearray and converted to bytes (to be consistent with the
> read method).
>
> I suppose the function is reliable. File is opened in binary mode and only
> b"\n" is searched as line end, as *nix tail (and python readline in binary
> mode) do. And bytes are returned. The caller can use them as is or convert
> them to a string using the encoding it wants, or do whatever its
> imagination can think :)
>
> Finally, it seems to me the function is quite simple.
>
> If all my affirmations are true, the three obstacles written by Chris
> should be passed.

Have you actually checked those three, or do you merely suppose them to be true?

> I'd very much like to see a CPython implementation of that function. It
> could be a method of a file object opened in binary mode, and *only* in
> binary mode.
>
> What do you think about it?

Still not necessary. You can simply have it in your own toolkit. Why
should it be part of the core language? How much benefit would it be
to anyone else? All the same assumptions are still there, so it still
isn't general, and you may as well just *code to your own needs* like
I've been saying all along. This does not need to be in the standard
library. Do what you need, assume what you can safely assume, and
other people can write different code.

I don't understand why this wants to be in the standard library.

ChrisA

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Wed, 11 May 2022 23:27:03 +0200
Lines: 52
Message-ID: <mailman.377.1652304462.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de HxD7WjBQ8xrEPlBQCAF8gwFDcExA1s/dAZa4Ddx5Y2qQ==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Wq/djOpg;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.013
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; '2022': 0.05; 'bunch':
0.05; 'library.': 0.05; 'python.': 0.08; 'angelico': 0.09;
'cc:addr:python-list': 0.09; 'pypi,': 0.09; 'url:search': 0.09;
'cc:no real name:2**0': 0.14; '*nix': 0.16; 'assumptions': 0.16;
'cpython': 0.16; 'else?': 0.16; 'fast,': 0.16; 'from:name:marco
sulla': 0.16; 'furthermore,': 0.16; 'general.': 0.16; 'language?':
0.16; 'mimic': 0.16; 'popular,': 0.16; 'simple:': 0.16; 'tests,':
0.16; 'toolkit.': 0.16; 'url:pypi': 0.16; 'wrote:': 0.16;
'python': 0.16; 'instead': 0.17; "can't": 0.17; 'implement': 0.19;
'it?': 0.19; 'cc:addr:python.org': 0.20; "i'd": 0.24; 'cc:2**0':
0.25; 'anyone': 0.25; 'questions,': 0.26; 'seems': 0.26; 'binary':
0.26; 'object': 0.26; "isn't": 0.27; 'chris': 0.28; 'blog': 0.30;
'received:209.85.160': 0.31; 'think': 0.32; 'question': 0.32;
'concept': 0.32; 'simple,': 0.32; 'message-id:@mail.gmail.com':
0.32; 'but': 0.32; "i'm": 0.33; 'same': 0.34; 'core': 0.34;
'package': 0.34; 'header:In-Reply-To:1': 0.34;
'received:google.com': 0.34; 'from:addr:gmail.com': 0.35; 'those':
0.36; 'really': 0.37; "it's": 0.37; 'received:209.85': 0.37;
'others': 0.37; 'file': 0.38; 'way': 0.38; 'could': 0.38;
'received:209': 0.39; 'quite': 0.39; 'least': 0.39; 'to.': 0.39;
'wed,': 0.39; 'still': 0.40; 'wants': 0.40; 'want': 0.40;
'should': 0.40; 'search': 0.61; 'method': 0.61; 'url-
ip:142.250.179/24': 0.61; 'subject': 0.63; 'simply': 0.63;
'imagine': 0.64; 'your': 0.64; 'benefit': 0.65; 'tool': 0.65;
'100%': 0.66; 'url:q': 0.67; 'exactly': 0.68; 'and,': 0.69;
'free': 0.72; 'mode,': 0.76; 'quick': 0.77; 'horrible': 0.84;
'merely': 0.84; 'three,': 0.84; 'mode.': 0.89; 'life,': 0.91;
'reliable.': 0.91; 'said.': 0.91; 'interested,': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=RuMM00L50AVfGeMweKdvY7k5foPRISfYY+glUgrFwbk=;
b=Wq/djOpgbwMEnpOiVpI4pH36tf9Zh0FnV7FPbEA90a69+584266O4+UdTqEcNZB3JX
3V/tJPV6xRYK5A/X7Qjf9iFbKtmMDayNuiZfYN4qHSBdCNFZ/p/ekG4mhg5NBS5CADfF
8VEZJQ6cc6WnRect0TWzLA8k2pHjMtz3EHgOvU+K2Fta52CiYd4i/hALGYMLyl+PQOPv
PpNtc+FIneziuM7fHt7FbiioSIlcUNu356Wut7x1Ik7sFFf/Jf8paWqMlfcgoE+oXg9D
Y12cDXK13Hz0x+NomCJiba+B4ZcTLckI/+GAJuZHDglgAsPAAHR7x4KZi2eS63339LXh
53Iw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=RuMM00L50AVfGeMweKdvY7k5foPRISfYY+glUgrFwbk=;
b=STxiBop6LMasHvto9o7P/Q47HP5PyWCTpK1lSciDn6pa1Iyw7kakvBUt1m/Ew+eg2c
HzA6Swn+QlY/60WC9ZOimsiXGnSazdT0x3PZOQnrzf8ZLA9oob72g2MziItEnnCDfnIi
77WHX0D+OCMADiFD4pDW7akhN+BnhafNyxaTb4VaTocS2f4m3SqWVwza7NC78tEOP0i0
hA1xGo06PgsrIK5EPCKjmcAhkWRSWg5W6qGYm5tHhc9YH1Oen6qnJiqxy9U6efoHlJo3
X7U5fcDFiTt/55eApaOXcU2K/S322NDpjeOChNztPVjZOZlwKj6JxGJJlhqvZk11FCPH
V84Q==
X-Gm-Message-State: AOAM531ZGq9wsXH90Sgsnm8wiBHs7O94czST8ah9bZo2ydlQ9BIFseSO
wkzM7tKaJkMguHH0BCGzqIpjNI+bRjVuAVeh5mpqM4xbEZA=
X-Google-Smtp-Source: ABdhPJylmMupp+68Y0dh7doLW3xAHfTez4keyRVYaeEQh0BbMZzAfyYW+NGC+qktGA47A+VkI98aktshc58R57AUSac=
X-Received: by 2002:a05:6870:2115:b0:e6:6ee9:628b with SMTP id
f21-20020a056870211500b000e66ee9628bmr3686125oae.1.1652304459782; Wed, 11 May
2022 14:27:39 -0700 (PDT)
In-Reply-To: <CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
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: <CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
 by: Marco Sulla - Wed, 11 May 2022 21:27 UTC

On Wed, 11 May 2022 at 22:09, Chris Angelico <rosuav@gmail.com> wrote:
>
> Have you actually checked those three, or do you merely suppose them to be true?

I only suppose, as I said. I should do some benchmark and some other
tests, and, frankly, I don't want to. I don't want to because I'm
quite sure the implementation is fast, since it reads by chunks and
cache them. I'm not sure it's 100% free of bugs, but the concept is
very simple, since it simply mimics the *nix tail, so it should be
reliable.

>
> > I'd very much like to see a CPython implementation of that function. It
> > could be a method of a file object opened in binary mode, and *only* in
> > binary mode.
> >
> > What do you think about it?
>
> Still not necessary. You can simply have it in your own toolkit. Why
> should it be part of the core language?

Why not?

> How much benefit would it be
> to anyone else?

I suppose that every programmer, at least one time in its life, did a tail.

> All the same assumptions are still there, so it still
> isn't general

It's general. It mimics the *nix tail. I can't think of a more general
way to implement a tail.

> I don't understand why this wants to be in the standard library.

Well, the answer is really simple: I needed it and if I found it in
the stdlib, I used it instead of writing the first horrible function.
Furthermore, tail is such a useful tool that I suppose many others are
interested, based on this quick Google search:

https://www.google.com/search?q=python+tail

A question on Stackoverflow really much voted, many other
Stackoverflow questions, a package that seems to exactly do the same
thing, that is mimic *nix tail, and a blog post about how to tail in
Python. Furthermore, if you search python tail pypi, you can find a
bunch of other packages:

https://www.google.com/search?q=python+tail+pypi

It seems the subject is quite popular, and I can't imagine otherwise.

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 07:31:34 +1000
Lines: 21
Message-ID: <mailman.378.1652304708.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
<CAPTjJmph1qfOyJW46jHbdiswsDHbLQLv2Pcv0i+mq21STmJxnA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de MPXT2ouERFsnk5MoNK6GUAFSSxjepu9jpPXju3E30suA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Z/f+tD7A;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.048
X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; '2022': 0.05; 'debug':
0.07; 'else.': 0.07; 'angelico': 0.09; '*nix': 0.16; 'chrisa':
0.16; 'fast,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris
angelico': 0.16; 'received:209.85.128.41': 0.16; 'received:mail-
wm1-f41.google.com': 0.16; 'tests,': 0.16; 'wrote:': 0.16;
"aren't": 0.19; 'thu,': 0.19; 'to:addr:python-list': 0.20;
'anyone': 0.25; 'else': 0.27; 'done': 0.28; 'chris': 0.28; 'it,':
0.29; 'think': 0.32; 'concept': 0.32; 'simple,': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'but': 0.32; "i'm": 0.33; 'someone':
0.34; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'those': 0.36; "it's": 0.37;
'received:209.85': 0.37; 'put': 0.38; 'received:209': 0.39;
'quite': 0.39; 'enough': 0.39; 'use': 0.39; 'to.': 0.39; 'wed,':
0.39; 'want': 0.40; 'should': 0.40; 'simply': 0.63; 'willing':
0.64; '100%': 0.66; 'and,': 0.69; 'care': 0.71; 'free': 0.72;
'yourself': 0.75; 'merely': 0.84; 'sulla': 0.84; 'three,': 0.84;
'reliable.': 0.91; 'said.': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=6yPt1qsAeJaOmgYvqfzCshdCBfsOs6HyFwMPydq7+R4=;
b=Z/f+tD7ADrEf7DiHr6Ja4MQsHJJrvsb8PCuspwCg8u+D+fItvD54XGlR8qiPrup68f
YYCeUXd8IpT/eUxzm3nZtFDVHrXoyUTzYjFrOQH1SBR5SAYlRpA1+gfXrZdWZjoJaGHb
H42Y2lc5NUcrHAGZJueX3WQuROc4zARD2OeBgfma+lwRTOdRadAekcpqLkL/T79qggDN
id8fymvdRADSRs5zxUQsTvlZd38Gyckhtap/kHrYTH6y/UdUbxa0ceI4QSEDw5l2LqRl
zTbr1fHo79QcmrWowO6b2Y5IqDSZ41azpR1O7RckIhWyZ1EEeY0mY4vwPIMr4Az/QqBX
u6+A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=6yPt1qsAeJaOmgYvqfzCshdCBfsOs6HyFwMPydq7+R4=;
b=2hGj/p/utOPyw+G2cqfCmHFSjkyyOwOZG7i/0SytdPEMtPO5LuQ7kMmQgMspC+gv7v
bVXDEmCJDTJW8tOXfBx+DYqB+zIuSBksw+aPDXD/fsLQOv3fAMN9dYMR1vtFg/B6uIEe
+eeUI/gGinSjG0PsjyPqyyyB44x8OToBSCyKmLSvijrzgxvoCHFNrN8glJujTIUJek/d
Hozk506QmDnXVFHBj3eeWpEEWakIDdN8d+MDJRNgcYxU+Oumc+Q7keiu/Bp1JdnnDucN
l9Vy6ZViHfL87A15HhsMOq2Ej+/bZxgZ5l0a/IGJqmyxuqw/a+SFzmWkMgAVjppomC5T
MIDQ==
X-Gm-Message-State: AOAM532c3D12BHQ+IaQmJFi/WOPXoCUs+pqkzauB6LjbJwqSKnfB5Xeg
93+QucmDQc6RqoHDop+QETCsOUb78mg+PXxjuoFtTYOR
X-Google-Smtp-Source: ABdhPJyn8z+Z97HUNidBcYNt75rlqbDdi076KBs+MnrNXij+BmPu/2YVNwYnJo5W5ZU0H68/8W5HilB5YmY3jdgs3uc=
X-Received: by 2002:a05:600c:3542:b0:394:6e2f:ffa2 with SMTP id
i2-20020a05600c354200b003946e2fffa2mr6862626wmq.132.1652304706131; Wed, 11
May 2022 14:31:46 -0700 (PDT)
In-Reply-To: <CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
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: <CAPTjJmph1qfOyJW46jHbdiswsDHbLQLv2Pcv0i+mq21STmJxnA@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
 by: Chris Angelico - Wed, 11 May 2022 21:31 UTC

On Thu, 12 May 2022 at 07:27, Marco Sulla <Marco.Sulla.Python@gmail.com> wrote:
>
> On Wed, 11 May 2022 at 22:09, Chris Angelico <rosuav@gmail.com> wrote:
> >
> > Have you actually checked those three, or do you merely suppose them to be true?
>
> I only suppose, as I said. I should do some benchmark and some other
> tests, and, frankly, I don't want to. I don't want to because I'm
> quite sure the implementation is fast, since it reads by chunks and
> cache them. I'm not sure it's 100% free of bugs, but the concept is
> very simple, since it simply mimics the *nix tail, so it should be
> reliable.

If you don't care enough to benchmark it or even debug it, why should
anyone else care?

I'm done discussing. You think that someone else should have done this
for you, but you aren't even willing to put in the effort to make this
useful to anyone else. Just use it yourself and have done with it.

ChrisA

Re: tail

<c0do7h9n0olk6ur3qo8och8oi5lrftr4np@4ax.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 11 May 2022 17:15:11 -0500
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Wed, 11 May 2022 18:15:10 -0400
Organization: IISS Elusive Unicorn
Message-ID: <c0do7h9n0olk6ur3qo8och8oi5lrftr4np@4ax.com>
References: <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com> <CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com> <mailman.363.1652123522.20749.python-list@python.org> <dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com> <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com> <CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com> <mailman.376.1652299651.20749.python-list@python.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 19
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-eHKMfklFNRMLaKRi/AanVZBgOlFezx3hludHSkVtCVlN2e9Zm5n91FAIoVa3A+e0qxRLc7xflZR68Fo!tAi0iXSVlfkCAgrNitcWjEiFPIltE59FmEyF2UWCYLAEXpGCHILp1yeHc7paVzG6GhPyOEwj
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 2147
 by: Dennis Lee Bieber - Wed, 11 May 2022 22:15 UTC

On Thu, 12 May 2022 06:07:18 +1000, Chris Angelico <rosuav@gmail.com>
declaimed the following:

>I don't understand why this wants to be in the standard library.
>
Especially as any Linux distribution probably includes the compiled
"tail" command, so this would only be of use on Windows.

Under recent Windows, one has an equivalent to "tail" IFF using
PowerShell rather than the "DOS" shell.

https://www.middlewareinventory.com/blog/powershell-tail-file-windows-tail-command/

or install a Windows binary equivalent http://tailforwin32.sourceforge.net/

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Re: tail

<spec-20220511233258@ram.dialup.fu-berlin.de>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: 11 May 2022 22:33:13 GMT
Organization: Stefan Ram
Lines: 9
Expires: 1 Apr 2023 11:59:58 GMT
Message-ID: <spec-20220511233258@ram.dialup.fu-berlin.de>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com> <YnijKH0NJdtDd2sa@cskk.homeip.net> <CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com> <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com> <CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com> <mailman.363.1652123522.20749.python-list@python.org> <dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com> <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com> <mailman.375.1652299133.20749.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de uqlTr5eR5b2DTwNWKEihtgG8S6ABWrp0WQ4qT/X+5rkr2o
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Wed, 11 May 2022 22:33 UTC

Marco Sulla <Marco.Sulla.Python@gmail.com> writes:
>def tail(filepath, n=10, chunk_size=100):
> if (n <= 0):
> raise ValueError(_err_n)
....

There's no spec/doc, so one can't even test it.

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigr...@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Wed, 11 May 2022 23:47:56 +0000 (UTC)
Lines: 72
Message-ID: <mailman.379.1652312880.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
<1960660253.1294402.1652312876126@mail.yahoo.com>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de /DegkxidvpBzBQUn1euabwC0BZk+nAvSaCcdeLfHIHHQ==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=YkH2ay6Y;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.027
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; '2022': 0.05; 'bunch':
0.05; 'issue.': 0.05; 'library.': 0.05; 'python.': 0.08;
'angelico': 0.09; 'cc:addr:python-list': 0.09; 'fyi,': 0.09;
'pypi,': 0.09; 'url:search': 0.09; '&gt;': 0.14; 'url:mailman':
0.15; '*nix': 0.16; 'assumptions': 0.16; 'cpython': 0.16; 'else?':
0.16; 'fast,': 0.16; 'furthermore,': 0.16; 'general.': 0.16;
'language?': 0.16; 'mimic': 0.16; 'popular,': 0.16; 'simple:':
0.16; 'tests,': 0.16; 'toolkit.': 0.16; 'url:pypi': 0.16;
'utilities': 0.16; 'wrote:': 0.16; 'python': 0.16; 'instead':
0.17; "can't": 0.17; 'implement': 0.19; 'it?': 0.19;
'cc:addr:python.org': 0.20; 'version': 0.23; 'command': 0.23;
"i'd": 0.24; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25;
'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0':
0.25; 'url-ip:188.166/16': 0.25; 'anyone': 0.25; 'questions,':
0.26; 'seems': 0.26; '11,': 0.26; 'binary': 0.26; 'object': 0.26;
"isn't": 0.27; 'done': 0.28; 'chris': 0.28; 'blog': 0.30; 'url-
ip:188/8': 0.31; 'think': 0.32; 'question': 0.32; 'concept': 0.32;
'simple,': 0.32; 'but': 0.32; "i'm": 0.33; 'focus': 0.33; 'same':
0.34; 'core': 0.34; 'package': 0.34; 'header:In-Reply-To:1': 0.34;
'those': 0.36; 'really': 0.37; "it's": 0.37; 'others': 0.37;
'file': 0.38; 'way': 0.38; 'could': 0.38; '8bit%:14': 0.38;
'changes': 0.39; 'quite': 0.39; 'least': 0.39; 'use': 0.39; 'to.':
0.39; 'wed,': 0.39; 'still': 0.40; 'beginning': 0.40; 'wants':
0.40; 'want': 0.40; 'should': 0.40; 'to:none': 0.60; 'search':
0.61; 'method': 0.61; 'skip:o 10': 0.61; 'from:': 0.62; 'to:':
0.62; 'subject': 0.63; 'simply': 0.63; 'skip:b 10': 0.63;
'imagine': 0.64; 're:': 0.64; 'received:74.6.135': 0.64; 'your':
0.64; 'benefit': 0.65; 'tool': 0.65; 'less': 0.65; '100%': 0.66;
'url:q': 0.67; 'back': 0.67; 'exactly': 0.68; 'and,': 0.69; 'cc:':
0.69; 'free': 0.72; 'skip:f 20': 0.75; 'mode,': 0.76; 'quick':
0.77; 'sent:': 0.78; 'header:Reply-To:1': 0.79; 'horrible': 0.84;
'merely': 0.84; 'pipeline': 0.84; 'sulla': 0.84; 'three,': 0.84;
'mode.': 0.89; 'life,': 0.91; 'reliable.': 0.91; 'said.': 0.91;
'interested,': 0.95
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1652312877; bh=MUwCMdn/bDxrBbAetyQfU5TrrlvPxAIJtEO+5Pqg9ag=;
h=Date:From:Reply-To:Cc:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=YkH2ay6YT2RhlW1a4pVyGuZQyS6prZclxGQ740PKBCmQsCccpWR9A1AfloXy29ffM2G+eYjhGrRf6Kh4BQfG3HLdzHqjUT6pteo6oS29PC4HLO4pnY3yVE6vjBdDmCqwT2UjSZTgT16flO5HjK5ImsOjIS7j85k4cxapH9FTkfuQVUFFBZ+R9v1NklNxNIrcYvvfmqucYa0iruJU+KvbqUa8wXYZn36AdzVGK/iagWg0gyOey6Zy7MTfe6F+IMd0GvBtUBbqtb3pIXHitrKQjuHG4D/fW6O6I4uGWX1iwD1HIVI/XPlSx93OWxxHPujUTo2WMehthUb3kMGL7uh1wg==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1652312877; bh=OL+5UV8+V9+Rni1NvG7SzSpuHs8OlJJ84GhNs3VQ2aT=;
h=X-Sonic-MF:Date:From:Subject:From:Subject;
b=Fb9MPfxBw52XP2i2zh5pqBBX/LoLuj04Yv819P2Io3VrjCCmf/Gck7i9HTNdNtqGb4pYU8JY/1ZOHLBuX1MLGWEaadiFhBZ4v6bVoEPDa09XutQUJ3p6bDBHjXXn+HE+zyVWrHwcHaWkTGOeHz0t0WCl9pDqTeQmsRaXUQOykrie8jYXwwg7IEgLH2S0bwbjhkyCIB0njwigwROOwBGBWrnT6omM78tBkNSZrwLhRcK1RNHnYk2twLB1VDH1/o8y2fcimmCYp9zJS6zl2el7sHq2ALdFlbzKquEeJrlBCxHBG/4AZL3o8WtJqFSrNEzUWejwX5r0oVHjVZRT5R0VHg==
X-YMail-OSG: rFN8Z3wVM1nud_stqpNUmPHpXY_sGjlyz7NB9OLXOwxp9HlMAmFS0K..Satshky
eYrqpOd3NtpMiUki4C8SIstSWZxitBTlTfrY9xX7Op.pbxwQ.YGwPkCUEX3Gn799n.54hZlGWsdb
D1HCtsjuMFt3NQSaD21asizEnxapXDeImK9L1mavWe2bPu0e12x_iKaSaZERpgAabc9Yokqh.Rdd
AqgfOo5hL_uapbkh.UVh_kAHzR.anSXK5xDK.915mEH9067t8dgY7m_s7vNhCmV7N.o_ALGfNKTf
L.sJ3DQnlpvFcDxn6MMNOz0n1N6LrkiKGYIIYZy3s8VGKFIR61_cTNCQATAAfq.20cHXnPJGou1x
5rJdyLdPjL9wVyrdgTDtsZTvfhsKRn1XkvxpI_5wYZRCLLEuKY45Q6S8_P0uNhBHMO9hA.2bttZR
7RZ5jVQPRUMkpqgeeKMG19SxjYlYpdJAo8udshURL6qYrQWMcYc0AaRtDx1v3JvEBk1ThWL0A8zj
18tHbyR1ihuvG08zXiIP7XpDWkDErAIiuZJhqBkFK4NyluYs2iOvqyzBivlJDbJJx7JMa_D0CBE.
2g37YfJy0SMi3p2HWlBeQj2qgbLo92ecN5pMJxMThQJszNeScpma4cVcko9U8lZpjp7eFWHlgJK0
_anGQp7TMQ71I5w3pfjqzM7kefSm7c4LzU6hLN9tZcYwHu8Jz.fI.XCp0dadq.0vSKHaZrsC6Mcr
SQ2sXqLR.K8.Sa4oGMEew46lIuA_AE5PVlyg1NeONrGGjgzHJG7f6nRsAEuHjG2UBgN0ZnPzloOS
XfYt_K2D1Idg6UXalPJ5F3zIHSjORFqQYHUKnUyOuBC8TBRuJuqaRqhTn8ezViyFU2LUidqac.LR
PZpiID4b6Tb5L4tNdJBQIj2SYVX.k0sm4FpQm6Rf0LAMhiYuBJRzABY4JOSvVvpxh62rvRfyE_Cb
cCtQmpcy3hl.LDzddLlbGBbVb_zl3WRjjuE4JAnLhmY.XrK42QSv8mwRGJarSyMAfF9QN.4FXeZt
oZo_q2r7_1qattF_2BkFo0wnAlkdJq4uKFDkK.RGzewInQQQhrEThjjWTq8xnG3o0o7nGOIksp79
Q1MKtsfC7hM8a.PJR3icZBn.7e1QmDrjl.NG_Ibcjdx91wuHii7jRquQ0vgT0Uf_PpW7k4vRE65J
4goXNliuAr5fz4B1NSRzGO0RYjUXvhp_rcQha4tor.OotZg8fTlOuF4WhU.__S5EfEMQvbJVKcAg
pZcMWDzjJzWGz7ObGmOGgBHKIDTKNFFnDpITD7oTBP53jru9FCHFea0X4yWceuYsDU7A6rSB0sIK
uZ1TpAuGa4JaHx2cC1cwchLcIaqVoQHD.v08SpwiRLzrh1pThQcw2MNWxNTjprTjY8.c1v.bE2iy
zEWPvlp3NxOkWsqm6bHpX2yHPqL0vVi067lrDnF0Ok8b3zH_jurJ6sx7obdLAgQKb4XVTbpLE5mZ
MGlvo34KkZ2qFyQKnYSSfNlQLsanpOQFE_Kc8QDQSFoWs3ucIET1Z5ppi6WN2i.zYJrCpga5y2oY
B1Ze9NWPKf6nEuFoJz3QbC.jKHMhZe8mipAyykXl6jn0f1YjmlRBPvyfBCjHcEFES1Ymi3u80MV.
Se8qi0g5i2wocijwU674oBUygq4Id_3HpD5MOBii0fcG0CufxEGsWjiGzyA8sQo0mjFLAFs4BleV
igTXySQmgV2Gsm3qDkDmZf_yqu8pWr0Fnj78i.HBQnSzLLigMmBEy7nGtlKqsmaQpgoFf_jIsDiu
ClnPIc3bNAIIJ_imIQCe3FWvG4xNS9xysnXVKtQ9HxCefz5Z09_kaq7s_EpQU5taS9ml7v9YeNvc
5mxfFZbCN4G71.wkLG3ggQFm86IDbyHU7DRkPwEBTM.33cPAcpzirY9rcbg7dgPqVeClYbVSRj4E
gMSJJhs6rU8u1mVf7xcXIPIpxVLYLEdsz_DKo3Rpgwcc.AIaEGFpFLoMcFDWJXIjx5.xf58Yintn
zbddxawyupG.v9GCBD.mYcdoFw_w4KEJhdtdBVfeuTtWkpVa4.vYalj32HJh__XboVqmzJjtbMse
QnPkHmOk1g7KbdIXnzN6xB8QvGi.hPMWyvJtqkTZFf_m8cKEeRpBAzeEQno4UQVFdS2LS3ORtIZi
AR7vxZb0f9xxpEMiur4DjSxCYEdhJ.epUcGMBlSX_.0r.wtvJytwHEUKfSVeW4KQHnmyEQ4JPa2j
gt4dKTDrfiasP8AryKd.C40RaD_8RPzLwnOWv5OI-
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
X-Mailer: WebService/1.1.20188 aolwebmail
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <1960660253.1294402.1652312876126@mail.yahoo.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<CABbU2U93uNVvXiPj0+H3FaUanL58ZKgKWPqgNrje2ed46JudpA@mail.gmail.com>
 by: Avi Gross - Wed, 11 May 2022 23:47 UTC

Just FYI, UNIX had a bunch of utilities that could emulate a vanilla version of tail on a command line.
You can use sed, awk and quite a few others to simply show line N to the end of a file or other variations. 
Of course the way many things were done back then had less focus on efficiency than how to stepwise make changes in a pipeline so reading from the beginning to end was not an issue.

-----Original Message-----
From: Marco Sulla <Marco.Sulla.Python@gmail.com>
To: Chris Angelico <rosuav@gmail.com>
Cc: python-list@python.org
Sent: Wed, May 11, 2022 5:27 pm
Subject: Re: tail

On Wed, 11 May 2022 at 22:09, Chris Angelico <rosuav@gmail.com> wrote:
>
> Have you actually checked those three, or do you merely suppose them to be true?

I only suppose, as I said. I should do some benchmark and some other
tests, and, frankly, I don't want to. I don't want to because I'm
quite sure the implementation is fast, since it reads by chunks and
cache them. I'm not sure it's 100% free of bugs, but the concept is
very simple, since it simply mimics the *nix tail, so it should be
reliable.

>
> > I'd very much like to see a CPython implementation of that function. It
> > could be a method of a file object opened in binary mode, and *only* in
> > binary mode.
> >
> > What do you think about it?
>
> Still not necessary. You can simply have it in your own toolkit. Why
> should it be part of the core language?

Why not?

> How much benefit would it be
> to anyone else?

I suppose that every programmer, at least one time in its life, did a tail.

> All the same assumptions are still there, so it still
> isn't general

It's general. It mimics the *nix tail. I can't think of a more general
way to implement a tail.

> I don't understand why this wants to be in the standard library.

Well, the answer is really simple: I needed it and if I found it in
the stdlib, I used it instead of writing the first horrible function.
Furthermore, tail is such a useful tool that I suppose many others are
interested, based on this quick Google search:

https://www.google.com/search?q=python+tail

A question on Stackoverflow really much voted, many other
Stackoverflow questions, a package that seems to exactly do the same
thing, that is mimic *nix tail, and a blog post about how to tail in
Python. Furthermore, if you search python tail pypi, you can find a
bunch of other packages:

https://www.google.com/search?q=python+tail+pypi

It seems the subject is quite popular, and I can't imagine otherwise.
--
https://mail.python.org/mailman/listinfo/python-list

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: avigr...@verizon.net (Avi Gross)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 01:27:20 +0000 (UTC)
Lines: 65
Message-ID: <mailman.380.1652318880.20749.python-list@python.org>
References: <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<mailman.376.1652299651.20749.python-list@python.org>
<c0do7h9n0olk6ur3qo8och8oi5lrftr4np@4ax.com>
<719424227.1299571.1652318840152@mail.yahoo.com>
Reply-To: Avi Gross <avigross@verizon.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de Y4O3orWpqIV53U4zs5dufAy49B5c2Y0a20S2HoPDeHzg==
Return-Path: <avigross@verizon.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=verizon.net header.i=@verizon.net header.b=jYh/+bYT;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.009
X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '2022': 0.05; 'bunch':
0.05; 'file?': 0.05; 'library.': 0.05; 'random': 0.05; 'windows,':
0.05; 'suggestion': 0.07; 'used.': 0.07; 'angelico': 0.09;
'linux': 0.09; 'numpy': 0.09; 'rarely': 0.09; 'smaller': 0.09;
'&gt;': 0.14; 'url:mailman': 0.15; 'memory': 0.15; 'compiled':
0.16; 'efficiently': 0.16; 'filename': 0.16; 'structures': 0.16;
'textual': 0.16; 'useful.': 0.16; 'windows.': 0.16; 'python':
0.16; 'probably': 0.17; 'thu,': 0.19; 'to:addr:python-list': 0.20;
'language': 0.21; 'languages': 0.22; 'install': 0.23; 'lines':
0.23; 'to:name:python-list@python.org': 0.24; 'skip:- 10': 0.25;
'url-ip:188.166.95.178/32': 0.25; 'url-ip:188.166.95/24': 0.25;
'url:listinfo': 0.25; 'programming': 0.25; 'url-ip:188.166/16':
0.25; 'seems': 0.26; '11,': 0.26; 'again,': 0.26; 'binary': 0.26;
'perform': 0.26; 'function': 0.27; 'chris': 0.28; 'environment':
0.29; 'packages': 0.31; 'takes': 0.31; 'default': 0.31; 'url-
ip:188/8': 0.31; 'end.': 0.32; 'files,': 0.32; 'structure': 0.32;
'but': 0.32; 'url:blog': 0.33; 'windows': 0.34; 'someone': 0.34;
'mean': 0.34; 'header:In-Reply-To:1': 0.34; 'particularly': 0.35;
'final': 0.35; 'files': 0.36; 'functions': 0.36; 'year': 0.36;
'lists': 0.37; 'special': 0.37; 'using': 0.37; 'others': 0.37;
'file': 0.38; 'way': 0.38; 'put': 0.38; 'read': 0.38; '8bit%:14':
0.38; 'text': 0.39; 'list': 0.39; 'use': 0.39; 'wed,': 0.39;
'wants': 0.40; 'something': 0.40; 'want': 0.40; 'provide': 0.60;
'url-ip:104.21/16': 0.61; 'skip:o 10': 0.61; 'from:': 0.62; 'to:':
0.62; 'skip:b 10': 0.63; 're:': 0.64; 'received:74.6.135': 0.64;
'wish': 0.66; 'numbers': 0.67; 'generally': 0.67; 'url:net': 0.68;
'following:': 0.69; 'obvious': 0.69; 'stores': 0.69; 'free': 0.72;
'head': 0.73; 'easy': 0.74; 'sent:': 0.78; 'header:Reply-To:1':
0.79; 'need.': 0.84; 'indexed': 0.84; 'lean': 0.84; 'start?':
0.84; 'url-ip:104.21.54/24': 0.84; 'url-ip:204.68.111.100/32':
0.84; 'url-ip:204.68.111/24': 0.84; 'url-ip:204.68/16': 0.84;
'url:sourceforge': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verizon.net; s=a2048;
t=1652318877; bh=19JhGETrISnP9JT6/yisHSg4phlgNNx9gLxzRTUrjrU=;
h=Date:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject:Reply-To;
b=jYh/+bYTRMK2h0xeKD8ZwihfAE9pt8SeJ5JzZPS3jOR1Wq7nsIm6CWgrZXagqk/Ol3Npp47TAXKMEQfHTYKo+GkHEgt8icpyy75Tm5fsn1nENSfzYBa+kfPSmoP2I6Ckhjtuw//2CxaL7mbOfd4p1fstDnk/2V5oQqre+4Ag5ArxO6KrgzyNc9oE1OcfsUcgyqPWX9N6bmdtuHgD1Cik5r7ux/YXSQ9JwqaD+VfBrGxDLx2iAARLxH0xHuLTbBTtZmWU/a1FJ063oSEGjhq96e2n+ZWyM4DCnOhQ0AxbRiIQOKvd0kkjUDEdiDR90lt1TtSAxP9uquffYmlkR4RLtQ==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
t=1652318877; bh=yh4gnTMWFTq6irjo1ov6HE1rlppXCk8GBU1ZAsEZr+X=;
h=X-Sonic-MF:Date:From:To:Subject:From:Subject;
b=KUHAewT+qpBmDPApNcJgIbiBRODdBX5g+n+vqdz/YyT0C4AQ0a2CetX4VQM1I6Ri5PaYwWyLEKRZdWwiWWjnVDr/kRs6RND5x3PQTrzLviLzQgUVP3mZOKYGLMWvqWw3o2bixzX1qA8atDs+TMczd6jriGXYlGB9g+JcoGXzHAC1f5RMBISnAHVVxpKuHc9vlP8XnO2s2QAmtgVcqj38DABCN635zODsIA636FHl72bQuM00CDhbnNyrK+oxmlstjip1mRLcgKKe3L/CyTzzTk8pGxyqr8Yqv4I31laQfqnI7QRluI8NWZAssqn/mSE/WZxbGYo+B+jNik/vhLsjRA==
X-YMail-OSG: Jul3dSMVM1nLql_9e4S1CALLrOeBvZZguc2f0E_kjBXzPl7Yhmzegq46v2xbmHK
aHZnN0Z.MKX_9zNxdve9C4mrxJ6rn4ESql.D2glBdQjzWFTBNN3zoRpSxgBA.xFk0TkLNF7Di3YD
uSzKieOIijpGVreWL_HzELSJD9EeYnU2Ga3Jk9TgI7xVQD_6VIzjlmqY8KtqL0Mlbq0uMNQDwtwS
ZuibGILfasmmD0o1IumrTqEBmAE5EEUCd0WMXGSFPV44NnschtBCkSGwtwOxZAeHqt3ows3nWvee
LXAHpjAtaF8DJ9LbjmSQIWfqck8IBdfPrKzT5cnFi3q6puS7f76cT8ULiwZUzUPWdAHFYj5L4LWz
ztkk.HIatdid6ox9.QNZ1B0vMFf8HCmMxCNJ41N0HQPu.61fgSxNNBxIugB50d7yPEhGLtgnfsAv
lDQDRLEpJdv6pRYCdyOuzF4pVDUfNEag7c4CRbSS.u3_QysmHq6auwhvrHWrpb7ZCS.L3gIum1n7
zG0GJuVO5eTcvrE23b7mpuPfh.gO7wN0_9cL0YvnwFbd6sFt6wQpvPXhstP4TjryXeBQAoULQbdg
TJ5kJjfiomgmGLR_hIPIYZ0O94RZqGhEDF0q.Q88MeV2Vj8AxhJyVpCLu6u3C.BieqDzSwxjVkSs
jzol7xXKq7vIL2nP9m9wAQBAqBPJtWPXOIzKivMmvzHuWjrsmEUjN_7RxTShWtMifWQNbsZJuz6_
VHcfAn9H8htf_PmpTBe._gKaE6ErGtX37VeHWd9nTBm8vYpM6hyDCOZi257hcwbrhM_GzDIFCPSF
AqCXqJ3GtrLznmy7mHbMIG0FQT4Gn61AEjwmxuFMCdnkduaFBcT.VM4bbw9UeLyurNlo_sj6ReBj
vXM6Eeyifd4e7FzYNM6VR7y9Im3rF3rWz_hXF6WEWio_A6Qr.4Hh88hdqq23X5wgI6ehMv7iQXmh
XCicHDEtgwE4U6Pu9Ee7AjDODHP8l1vmjLGx9UFD808SS3GPVuyKZ0EjzXQZ4LLhl5A.Z8SmtBzN
QbM5v7MthqNfe107PvMkGTYdAhqyZb8CTNn6L3o0LDrf6uL9DZStIhaDUHCxkIXMdcSiK1V4Kvia
lRWrGDHtcRfgcQAxxePIZsNempoDoK4.JEhXOaM3tG88B41doocfkS5XOyEQNLn54lkqN2EqtJyl
T0FaYh8gD9fRiRouaUBLUbO7exS.91p_knE7MVQd5eTxfOWV8TsXIMGAHye.kLnTiVoK6fWVEtJ5
IZBgzpwHbvcYYg4iLp9ochuECJQNbVvkqIfIPW6kNvIW2bdl1LHFpGtI.1UbsPbj6CClZZFCPmHR
a0xn5Kdo.JBj2LFPRW8MXVMXPDOAbUYcZBW3g.wmaifjuBfFlJzr47E8Wv28qhSodCwQ_i_N3f0a
cxzE1ZabicSdhVCnPgH_X1diuu3ZQcQO_QgosaRA9RufsbVbVxC_2dxX7tbI.j3AeuOgFJuNmfRO
STsA7vCJsipikkqRFiTqowueH9EjoCczUHCgPVRfNJ520pmRHjpoezYzmw9vVdkF_NPCvhCrt4er
H2M9OMaB.Eft0_CyTl8l5feWPXyKNsuFQQp7354tKZfR0AGcB8EucLRt6vgsdQUJbtCVnDBEUUOG
7tJImdB93d_RoIrSZisdh8tBgbwHi2POIpqVGPNnDMP5xi_eSVJgVYaPgJ6t7xEWSBQOEiYhS3cM
jH0qnfiwLEaRqC_dQ7mvMtGVe.YdOlb3yAqrAGZ3_Z3kAvX.3YZwTq1G2AhjgLNNKORNujwzA686
w0.DJyKy2qh6XaiLyQjAoGFcBl9tD.UgW80oiHuIzkcUyZonmiwHzZ16eAAUDF6XysKuBYYbidoH
pOhR7NhO3.jpMFyC.dYJev5fu1EopXrGV0M462tDGjTHeGuq2EIE3GkKPsOgF7UnI8nPQxWBdK3.
88gOihH4CWmvPKp0S6gDfK9Es8p9OeIuuQqeD5yaVtfp1ZPydIbYkQQHxSg5wdAfW6ZhbeUrjVyc
R50K8Zu6ht2_FugT7FfeQ2OHA0u1T3BgIzfupyExjK7YlCeo6SPIyYveeO3UGtqmQADzPIRVYjOr
GTf3EDiHxVFhwxJTwxtfu5GA7Swn30OZ_n_CMUCYOMTnWJzYALEPvPINJemUw_AgfZznL21yWhQr
EioK_vGn7OXMDYuHtjaKGxCUNsU2VH6oCQF0CanfJGZ2ckQfgekUp.q1.pEnNbGH2MJtBSzrEo_0
UjnybknX1bYfxBJ4Yh6E_v1zwtxY9qz7t
X-Sonic-MF: <avigross@verizon.net>
In-Reply-To: <c0do7h9n0olk6ur3qo8och8oi5lrftr4np@4ax.com>
X-Mailer: WebService/1.1.20188 aolwebmail
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <719424227.1299571.1652318840152@mail.yahoo.com>
X-Mailman-Original-References: <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<CAPTjJmoA6LbGo6WU29=uPVt3F4XuENLF-ZzxdOdRZrhYSm0DFQ@mail.gmail.com>
<mailman.376.1652299651.20749.python-list@python.org>
<c0do7h9n0olk6ur3qo8och8oi5lrftr4np@4ax.com>
 by: Avi Gross - Thu, 12 May 2022 01:27 UTC

This seems to be a regular refrain where someone wants something as STANDARD in a programming language or environment and others want to keep it lean and mean or do not see THIS suggestion as particularly important or useful.
Looking at the end of something is extremely common. Packages like numpy/pandas in Python often provide functions with names like head or tail as do other languages where data structures with names like data.frame are commonly used. These structures are in some way indexed to make it easy to jump towards the end. Text files are not.

Efficiency aside, a 3-year-old (well, certainly a 30 year old)  can cobble together a function that takes a filename assumed to be textual and reads the file into some data structure that stores the lines of the file and so it can be indexed by line number and also report the index of the final line. The data structure can be a list of lists or a dictionary with line numbers as keys or a numpy ...

So the need for this functionality seems obvious but then what about someone who wants a bunch of random lines from a file? Need we satisfy their wish to pick random offsets from the file and get the line in which the offset is in middle of or the one about to start? Would that even be random if line lengths vary? Text files were never designed to be used efficiently except for reading and writing and certainly not for something like sorting.

Again, generally you can read in the darn file and perform the operation and free up whatever memory you do  not need. If you have huge files, fine, but then why make a special function be part of the default setup if it is rarely used? Why not put it in a module/package called BigFileBatches alongside other functions useful to do things in batches? Call that when needed but for smaller files, KISS.

-----Original Message-----
From: Dennis Lee Bieber <wlfraed@ix.netcom.com>
To: python-list@python.org
Sent: Wed, May 11, 2022 6:15 pm
Subject: Re: tail

On Thu, 12 May 2022 06:07:18 +1000, Chris Angelico <rosuav@gmail.com>
declaimed the following:

>I don't understand why this wants to be in the standard library.
>
    Especially as any Linux distribution probably includes the compiled
"tail" command, so this would only be of use on Windows.

    Under recent Windows, one has an equivalent to "tail" IFF using
PowerShell rather than the "DOS" shell.

https://www.middlewareinventory.com/blog/powershell-tail-file-windows-tail-command/

or install a Windows binary equivalent http://tailforwin32.sourceforge.net/

--
    Wulfraed                Dennis Lee Bieber        AF6VN
    wlfraed@ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/
--
https://mail.python.org/mailman/listinfo/python-list

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 19:48:49 +0200
Lines: 20
Message-ID: <mailman.386.1652377768.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<mailman.375.1652299133.20749.python-list@python.org>
<spec-20220511233258@ram.dialup.fu-berlin.de>
<CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de R388XVACe/ZtNWCxPyVLBAQhbQjbcend9eYXP2CWzg3g==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=RL/PcH6M;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '2022': 0.05; 'ram': 0.07;
'"""': 0.09; 'cc:addr:python-list': 0.09; 'writes:': 0.09; 'cc:no
real name:2**0': 0.14; 'from:name:marco sulla': 0.16;
'received:209.85.167.173': 0.16; 'received:mail-
oi1-f173.google.com': 0.16; 'right.': 0.16; 'to:addr:ram': 0.16;
'to:addr:zedat.fu-berlin.de': 0.16; 'to:name:stefan ram': 0.16;
'wrote:': 0.16; "can't": 0.17; 'thu,': 0.19; 'cc:addr:python.org':
0.20; 'lines': 0.23; 'cc:2**0': 0.25; 'stefan': 0.26; 'function':
0.27; 'raise': 0.31; 'message-id:@mail.gmail.com': 0.32; 'path':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'from:addr:gmail.com': 0.35; 'received:209.85': 0.37; 'file':
0.38; 'received:209': 0.39; 'use': 0.39; "there's": 0.61;
'numbers': 0.67; 'means,': 0.84; 'sulla': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=ZKpJCTPX+jD+ITVIyRIuXL8GWg8qj77j+mNVwgS0fVA=;
b=RL/PcH6MSRM0UHGVoPOkeLAQId8FMeL22g/p7x4nmCnK5SbmRPptZLN8lMczo1RGwE
z5Ju1PQi5C/bYMtmtM6usMMEYSCgT9fw5dcXr5wlACsBYbI6wdZiwPPFWDJZMPjErsA3
p7eJEoHZCEyhUC/3ziHnQh7rCYQpD9EDpORnoEaKonyG35LM1N4zJQpUlhqIDkRC2SHB
row/nc7PMw3pAVdQUxP1B5qDEjmLlR5+nKfcoX+qzHqfUKAr1rOgWnQWf0i81yjh2bX5
BzLgTKMGZCYmtSq6kx7psgAtSbQyjG987CbdOs5l0vrgQktbfs+I58DtS77hid9Gv4eg
PJVw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=ZKpJCTPX+jD+ITVIyRIuXL8GWg8qj77j+mNVwgS0fVA=;
b=iTWmQrWpROISV8Mm96wFhyZBqLYdfoCzMoDBx23WX5mqZNSJL1GDHMRsdKS1PA7egn
2R0CzsK1SYRFjcy8ifF3Wh2ajGErh/QWkGvkQyWNzKfflU07tHVtwDmfoXKffUQ8UmFA
b2rbtl7H628kAnwoVYBBFhWGPkJbkiWUKXGZIsttk1lpof5zB8/Tw2B8NgejTRUbj2v8
WroUCN43azLUwUq0v0NfYFUFxnzYriVxFkCQDVvLRc3mlm38rm9CuTCUiviPtumATgih
hCsWQejUyGnaAYhXdrwrYxYu3Gm7+hDrMVgOgpDXpq+/AVQJHhg4K4StTva+kX5ZV5Z5
+32g==
X-Gm-Message-State: AOAM530PPIBeSuhdgj5rBHjpMcKPllESgKHcUDZb/b1S0u9z326JKrUm
0XmP2mPVkK+gPp5ufQYSLe3zPh8xay0jFWE2urc=
X-Google-Smtp-Source: ABdhPJxVwI++zrLtsDKgCqYMFFbJLDBmDDFmt6l4qMDlLKoCST9s4cDrI1kqnIJNlnAQTvbjoH8m03C8T+8ro4URKeg=
X-Received: by 2002:a05:6808:148e:b0:326:abe8:af49 with SMTP id
e14-20020a056808148e00b00326abe8af49mr6019739oiw.73.1652377766067; Thu, 12
May 2022 10:49:26 -0700 (PDT)
In-Reply-To: <spec-20220511233258@ram.dialup.fu-berlin.de>
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: <CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<mailman.375.1652299133.20749.python-list@python.org>
<spec-20220511233258@ram.dialup.fu-berlin.de>
 by: Marco Sulla - Thu, 12 May 2022 17:48 UTC

On Thu, 12 May 2022 at 00:50, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
>
> Marco Sulla <Marco.Sulla.Python@gmail.com> writes:
> >def tail(filepath, n=10, chunk_size=100):
> > if (n <= 0):
> > raise ValueError(_err_n)
> ...
>
> There's no spec/doc, so one can't even test it.

Excuse me, you're very right.

"""
A function that "tails" the file. If you don't know what that means,
google "man tail"

filepath: the file path of the file to be "tailed"
n: the numbers of lines "tailed"
chunk_size: oh don't care, use it as is
"""

Re: tail

<tail-20220512191824@ram.dialup.fu-berlin.de>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram...@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: 12 May 2022 18:20:23 GMT
Organization: Stefan Ram
Lines: 41
Expires: 1 Apr 2023 11:59:58 GMT
Message-ID: <tail-20220512191824@ram.dialup.fu-berlin.de>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com> <YnijKH0NJdtDd2sa@cskk.homeip.net> <CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com> <CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com> <CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com> <mailman.363.1652123522.20749.python-list@python.org> <dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com> <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com> <mailman.375.1652299133.20749.python-list@python.org> <spec-20220511233258@ram.dialup.fu-berlin.de> <CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com> <mailman.386.1652377768.20749.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de msgqmksGiJbADwg2qdQGFANC4X/1g/6zww5qY9xbDzY0ys
X-Copyright: (C) Copyright 2022 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE, en-US, it, fr-FR
 by: Stefan Ram - Thu, 12 May 2022 18:20 UTC

Marco Sulla <Marco.Sulla.Python@gmail.com> writes:
>"""
>A function that "tails" the file. If you don't know what that means,
>google "man tail"
>
>filepath: the file path of the file to be "tailed"
>n: the numbers of lines "tailed"
>chunk_size: oh don't care, use it as is
>"""

I am not aware of a definition of "line" above,
but the PLR says:

|A physical line is a sequence of characters terminated
|by an end-of-line sequence.

. So 10 lines should have 10 end-of-line sequences.

The following try prints "9" here:

import pathlib

# insert code for "tail" here

path = pathlib.Path( r"tmp20220512190720.txt" )

with path.open( "wb" ) as f:
for i in range( 100 ):
f.write( b"abc\n" );

result = tail( path, 10 )

print( result.count( b"\n" ))

. This also can be compared with

tail -10 tmp20220512190720.txt | tr -dc '\n' | wc -c

in the shell, which prints "10" here.

Re: tail

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

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: Marco.Su...@gmail.com (Marco Sulla)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 22:45:42 +0200
Lines: 76
Message-ID: <mailman.388.1652388382.20749.python-list@python.org>
References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<mailman.375.1652299133.20749.python-list@python.org>
<spec-20220511233258@ram.dialup.fu-berlin.de>
<CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
<mailman.386.1652377768.20749.python-list@python.org>
<tail-20220512191824@ram.dialup.fu-berlin.de>
<CABbU2U9PLsENvbVuBX0JWStug4XGbPUMxoCfAhtGxcpoc9J-mA@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de /XN8JMtaN+2V5fDd6tVpRQ4oP3mdOWd7iqXWih5b1F9Q==
Return-Path: <elbarbun@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=fhMPhJya;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'def': 0.04; '2022': 0.05;
'ram': 0.07; 'cc:addr:python-list': 0.09; 'cc:no real name:2**0':
0.14; 'import': 0.15; '&lt;': 0.16; '-1:': 0.16; 'email addr:zedat
.fu-berlin.de&gt;': 0.16; 'email name:&lt;ram': 0.16;
'from:name:marco sulla': 0.16; 'integer': 0.16; 'number"': 0.16;
'says:': 0.16; 'to:addr:ram': 0.16; 'to:addr:zedat.fu-berlin.de':
0.16; 'to:name:stefan ram': 0.16; 'wrote:': 0.16; 'thu,': 0.19;
'cc:addr:python.org': 0.20; 'maybe': 0.22; 'skip:_ 10': 0.22;
'lines': 0.23; 'cc:2**0': 0.25; 'stefan': 0.26; 'raise': 0.31;
'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'received:google.com': 0.34; 'from:addr:gmail.com':
0.35; 'received:209.85': 0.37; 'file': 0.38; 'received:209': 0.39;
'text': 0.39; 'break': 0.39; 'much.': 0.39; 'should': 0.40;
'physical': 0.60; 'skip:b 30': 0.61; 'skip:o 10': 0.61; 'skip:o
20': 0.63; 'true': 0.63; 'skip:b 10': 0.63; 'definition': 0.64;
'improve': 0.66; 'sequence': 0.69; 'above,': 0.70; 'skip:f 20':
0.75; 'characters': 0.84; 'sequence.': 0.84; 'positive': 0.86
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc; bh=tVoJEBrXiAeNkxRtTMBEAc1bif3krb8AqvFlJ1FdJJg=;
b=fhMPhJyaD48d0cZFn/eXmVxnkcNx7BuxpIkEfZMt908wVbAZ8r7ggCUFsC1YQct7EG
T9dnqlLZhPcY4gtL/G242er5QNzRoMdHauroVgHam2hbYi7x6ywmvk7tvNszHZAs51Bk
xiU1UxHoO76gafEW9jLi315KbPKUZx50d9o+8S+0F97Aj4ElQzNY59HMCn//tY3/ft1T
OW5gQ5sn9WQ7ee4YaghfWQeJfJx+uqH9Ul4Qynj9zmpzopvDCGMkTOU08bRLwSmYfHml
xzdz+NxVThTbwMd+OBNIlHN4JhuMi6txqAvYjS8FTCy6i6EnBgaxEhNepowRolK1Iw95
bR8A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=tVoJEBrXiAeNkxRtTMBEAc1bif3krb8AqvFlJ1FdJJg=;
b=aNYsBTXKrkVoWFMRjdchggTGZpRLDLwke3zwiOlQhmAIFb7mD7V/t4EIagPzDOMflw
eqpisA5RuI45/Ueqz1qtaPx4bNJDnbKXL4hzRFgnyJL1jZgdwlGLa1PssUwbTM4522XY
52V4TJ7R8X6Bypn1GZUzjqympl+vGw7L5uQ6ZVvXPJptcUTPBkoC/qCwHWK008ZItQra
EbQi/CsxA/u+PDqzowv5o86z2IWEGy0YXc2ceP2I77f3XNjQ1EIn9TrLbtibtRBWXa5i
X25F9/Oh2SPLDStuUEScMqLFfOoCRrOOtx4aH6MLi8MCB3CjnD/3GKQpU9qORcliHHZQ
+heg==
X-Gm-Message-State: AOAM5314OoIzf+WebF+34R5nsUoWcL/LROEh7p2sdZUMHwQVPOpLHimV
cQo7zENHsYGyQtx1DKJXC9+uY+eWFKNkhUtaECdr6dadfwM=
X-Google-Smtp-Source: ABdhPJw0Dhb/BLTacU3aEAf3lWy0jqh+wHiN4Bp8lLZ9QRlxlRhjednvIo5nqpdvsoXO5G2/2oObr39lwS3A+P92r/w=
X-Received: by 2002:aca:3088:0:b0:326:d72b:3ea1 with SMTP id
w130-20020aca3088000000b00326d72b3ea1mr5811676oiw.1.1652388379079; Thu, 12
May 2022 13:46:19 -0700 (PDT)
In-Reply-To: <tail-20220512191824@ram.dialup.fu-berlin.de>
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
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: <CABbU2U9PLsENvbVuBX0JWStug4XGbPUMxoCfAhtGxcpoc9J-mA@mail.gmail.com>
X-Mailman-Original-References: <CABbU2U8u-arOsEO=JfRUPeNQS68TYWVUYHvp6StiNpp_xaotZQ@mail.gmail.com>
<YnijKH0NJdtDd2sa@cskk.homeip.net>
<CABbU2U8iThoCk9M0agJMqAFDq0A9hzY5kQUMW=Jm5C94NkP28Q@mail.gmail.com>
<CAPTjJmqNNrk2gjN4=nX-Ai5Y1ysd4rsWGdyfU8Aqt1=Y1_Z-cQ@mail.gmail.com>
<CABbU2U-TLMLnWSJgOK6a8LaWWrwk+kcs801-_L=Wr2ijrLAdvQ@mail.gmail.com>
<mailman.363.1652123522.20749.python-list@python.org>
<dlvi7hp3dltj4v86l59rdhr9nc0lgj82k9@4ax.com>
<CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com>
<mailman.375.1652299133.20749.python-list@python.org>
<spec-20220511233258@ram.dialup.fu-berlin.de>
<CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com>
<mailman.386.1652377768.20749.python-list@python.org>
<tail-20220512191824@ram.dialup.fu-berlin.de>
 by: Marco Sulla - Thu, 12 May 2022 20:45 UTC

Thank you very much. This helped me to improve the function:

import os

_lf = b"\n"
_err_n = "Parameter n must be a positive integer number"
_err_chunk_size = "Parameter chunk_size must be a positive integer number"

def tail(filepath, n=10, chunk_size=100):
if (n <= 0):
raise ValueError(_err_n)

if (n % 1 != 0):
raise ValueError(_err_n)

if (chunk_size <= 0):
raise ValueError(_err_chunk_size)

if (chunk_size % 1 != 0):
raise ValueError(_err_chunk_size)

n_chunk_size = n * chunk_size
pos = os.stat(filepath).st_size
chunk_line_pos = -1
newlines_to_find = n
first_step = True

with open(filepath, "rb") as f:
text = bytearray()

while pos != 0:
pos -= n_chunk_size

if pos < 0:
pos = 0

f.seek(pos)
chars = f.read(n_chunk_size)
text[0:0] = chars
search_pos = n_chunk_size

while search_pos != -1:
chunk_line_pos = chars.rfind(_lf, 0, search_pos)

if first_step and chunk_line_pos == search_pos - 1:
newlines_to_find += 1

first_step = False

if chunk_line_pos != -1:
newlines_to_find -= 1

if newlines_to_find == 0:
break

search_pos = chunk_line_pos

if newlines_to_find == 0:
break

return bytes(text[chunk_line_pos+1:])

On Thu, 12 May 2022 at 20:29, Stefan Ram <ram@zedat.fu-berlin.de> wrote:

> I am not aware of a definition of "line" above,
> but the PLR says:
>
> |A physical line is a sequence of characters terminated
> |by an end-of-line sequence.
>
> . So 10 lines should have 10 end-of-line sequences.
>

Maybe. Maybe not. What if the file ends with no newline?

Re: tail

<h00r7hh87v9gtcd3658vmoetoj65cg2rl6@4ax.com>

 copy mid

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

 copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!buffer2.nntp.dca1.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 12 May 2022 16:48:26 -0500
From: wlfr...@ix.netcom.com (Dennis Lee Bieber)
Newsgroups: comp.lang.python
Subject: Re: tail
Date: Thu, 12 May 2022 17:48:25 -0400
Organization: IISS Elusive Unicorn
Message-ID: <h00r7hh87v9gtcd3658vmoetoj65cg2rl6@4ax.com>
References: <CABbU2U9sXbs5tKuOkgtCpprkypQsOwx-_=TxhXhnE0kj9=DsGA@mail.gmail.com> <mailman.375.1652299133.20749.python-list@python.org> <spec-20220511233258@ram.dialup.fu-berlin.de> <CABbU2U9HHADoY9ysgtoBtPnyu7UEaozCayuRRbc7UaVZPnvCLw@mail.gmail.com> <mailman.386.1652377768.20749.python-list@python.org> <tail-20220512191824@ram.dialup.fu-berlin.de> <CABbU2U9PLsENvbVuBX0JWStug4XGbPUMxoCfAhtGxcpoc9J-mA@mail.gmail.com> <mailman.388.1652388382.20749.python-list@python.org>
User-Agent: ForteAgent/8.00.32.1272
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 14
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-kICcta5/HvJsi3aAH1TQnCNPTHSqdaYb9BR/Ub9Nc6D+/L2ynDD5bEdbGjFu/8j0fwR98vp2imxkYIf!d4lH79u4kBtsFY4f+/MtT2RDekL8lpf3p4+SKZi0VkOdowandK73E9c5WFRHqXiV3R3lvVJn
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1911
 by: Dennis Lee Bieber - Thu, 12 May 2022 21:48 UTC

On Thu, 12 May 2022 22:45:42 +0200, Marco Sulla
<Marco.Sulla.Python@gmail.com> declaimed the following:

>
>Maybe. Maybe not. What if the file ends with no newline?

https://github.com/coreutils/coreutils/blob/master/src/tail.c
Lines 567-569 (also lines 550-557 for "bytes_read" determination)

--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

1
server_pubkey.txt

rocksolid light 0.9.7
clearnet tor