Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

C for yourself.


devel / comp.lang.python / Re: Extract lines from file, add to new files

SubjectAuthor
o Re: Extract lines from file, add to new filesdn

1
Re: Extract lines from file, add to new files

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: PythonL...@DancesWithMice.info (dn)
Newsgroups: comp.lang.python
Subject: Re: Extract lines from file, add to new files
Date: Mon, 15 Jan 2024 11:29:02 +1300
Organization: DWM
Lines: 80
Message-ID: <mailman.45.1705271350.15798.python-list@python.org>
References: <5a6d88e-46b1-a3ea-333-d053cbe5654d@appl-ecosys.com>
<24aeb00e-41fd-4809-ae96-d429645cbc07@mrabarnett.plus.com>
<4a215b7d-f1af-49d7-1496-96e290255314@appl-ecosys.com>
<65A0E32A.2458.26DB92@RealGrizzlyAdams.vivaldi.net>
<CAJQBtgnNs6q_+MrPsir4Kioh8Zra+UepDiwx61c0NXcm3P3xOw@mail.gmail.com>
<76935eb3-ed67-428e-9aea-a8e527e12914@DancesWithMice.info>
<CAPTjJmqc6g9oBLMh9Mt6K5ozN+xUJJJ68TjHBHnMXAS62mydew@mail.gmail.com>
<CAJQBtg=+_46_NDqYcpbf+heO4RjStvpJOuui9wgKmiEDinS9jg@mail.gmail.com>
<CAPTjJmrvUxenuBptvTDKiXptnzvLZQRhhYR_nuRTGibE5LaB3Q@mail.gmail.com>
<CAJQBtgk23N+TZ-Wce2iHwZo4pGX14gL2+k6NDre=TJ4c96wt=A@mail.gmail.com>
<CAPTjJmqxy7CdqfgX0GQDQB8C4t35rUrrch3yM_wG1jJ6rU0k5w@mail.gmail.com>
<02b201da471c$c6bafad0$5430f070$@gmail.com>
<CAJQBtgntgGc6oFqLS0nKuG8tAZT+fSA0d6on3Xw=0rHB_mANBQ@mail.gmail.com>
<CAPTjJmq2iXXuiRa0CHPddBQHm3kcoxGWW42sVAJKT9TUFxDiJw@mail.gmail.com>
<8d468f66-4a25-4450-972a-54a41e125153@DancesWithMice.info>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de xYpXMaNQb5GBgoWO03R34g1pECsUOEHpsQAMCCHLvW7g==
Cancel-Lock: sha1:h+9GlfFQIn+Ihxm+5eM1fO6vCNs= sha256:ZX2mrOcLHKFWRELdKpKoDhtCMfSmkf3dM4DjPmIrL7Q=
Return-Path: <PythonList@DancesWithMice.info>
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=danceswithmice.info header.i=@danceswithmice.info
header.b=lPnzOOHz; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'comments': 0.03;
'python?': 0.03; 'def': 0.04; 'fairly': 0.05; "python's": 0.05;
'variable': 0.05; 'loop': 0.07; 'subject:add': 0.07; 'used.':
0.07; '(?)': 0.09; '=dn': 0.09; 'angelico': 0.09;
'from:addr:danceswithmice.info': 0.09; 'from:addr:pythonlist':
0.09; 'received:192.168.1.64': 0.09; 'situation,': 0.09;
'subject:files': 0.09; 'url:reference': 0.09; '10:23,': 0.16;
'2024': 0.16; 'be)': 0.16; 'elaborate.': 0.16; 'message-
id:@DancesWithMice.info': 0.16; 'received:cloud': 0.16;
'received:rangi.cloud': 0.16; 'such,': 0.16; 'useful.': 0.16;
'was:': 0.16; 'which,': 0.16; 'whilst': 0.16; 'wrote:': 0.16;
'python': 0.16; 'says': 0.17; 'instead': 0.17; 'to:addr:python-
list': 0.20; 'language': 0.21; "i've": 0.22; 'subject:file': 0.22;
'(and': 0.25; 'python,': 0.25; 'discussion': 0.25; 'section':
0.25; 'cannot': 0.25; 'anyone': 0.25; 'object': 0.26; 'function':
0.27; '>>>': 0.28; 'chris': 0.28; 'etc': 0.28; 'sense': 0.28;
'example,': 0.28; 'header:User-Agent:1': 0.30; 'comment': 0.31;
'header:Organization:1': 0.31; 'think': 0.32; 'question': 0.32;
'logical': 0.32; 'python-list': 0.32; 'said,': 0.32; 'structure':
0.32; 'received:192.168.1': 0.32; 'but': 0.32; 'there': 0.33;
'hold': 0.33; 'header:In-Reply-To:1': 0.34; 'mon,': 0.36;
'possibly': 0.36; 'subject:from': 0.37; 'received:192.168': 0.37;
'could': 0.38; 'put': 0.38; 'two': 0.39; '(see': 0.40; 'both':
0.40; 'something': 0.40; 'skip:h 10': 0.61; "there's": 0.61;
'to:': 0.62; 'everything': 0.63; 'skip:b 10': 0.63; 'identify':
0.64; 'down': 0.64; 'full': 0.64; 'definition': 0.64; 'his': 0.65;
'came': 0.65; 'earlier': 0.67; 'prevent': 0.67; 'right': 0.68;
'rules': 0.70; 'head': 0.73; 'name,': 0.75; 'led': 0.81; 'left':
0.83; 'apparent': 0.84; 'danger': 0.84; 'declaration,': 0.84;
'disappearing': 0.84; 'narrow': 0.84; 'quotation': 0.84; 'says,':
0.84; 'grammar': 0.91
DKIM-Filter: OpenDKIM Filter v2.11.0 vps.rangi.cloud 0BDFB302E
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=danceswithmice.info;
s=staff; t=1705271348;
bh=yhMCHoNHr4e2jiFgSGowN3xBW2CDRJ6Et/sPHhRp3Z0=;
h=Date:From:Subject:To:References:In-Reply-To:From;
b=lPnzOOHzH1Y+KNBfOsGUV++C6lNhfgskDYOe3wjNgfdLH8E9LQNg07oJxsZTagFZ0
oUbVD11V4XcjvWGQWmsMZdYNYn5I2EXO4/Rf047D86sdEtG3xQltyFGdgYtuqQGnm/
bwrYE9rNPVu8c8mbJz1ofYFtU4sQCsmapUzepPyUianKkhIF4WkBVkvucvRxPw/Eu+
KPdixpI6YYw6iOqI1YSSLOnJbUftVADVWnsS9BfxGQ3Myy6ygm+HJNSChnXSmWD8+j
N6xfv2hrEL0xSbYUPkPSYGvPPPD0jfsjj7vBywDyLzhQs3d96/3XbZy8IlPIwbwGPk
MYPgPBPoJybVg==
User-Agent: Mozilla Thunderbird
Content-Language: en-US
In-Reply-To: <CAPTjJmq2iXXuiRa0CHPddBQHm3kcoxGWW42sVAJKT9TUFxDiJw@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: <8d468f66-4a25-4450-972a-54a41e125153@DancesWithMice.info>
X-Mailman-Original-References: <5a6d88e-46b1-a3ea-333-d053cbe5654d@appl-ecosys.com>
<24aeb00e-41fd-4809-ae96-d429645cbc07@mrabarnett.plus.com>
<4a215b7d-f1af-49d7-1496-96e290255314@appl-ecosys.com>
<65A0E32A.2458.26DB92@RealGrizzlyAdams.vivaldi.net>
<CAJQBtgnNs6q_+MrPsir4Kioh8Zra+UepDiwx61c0NXcm3P3xOw@mail.gmail.com>
<76935eb3-ed67-428e-9aea-a8e527e12914@DancesWithMice.info>
<CAPTjJmqc6g9oBLMh9Mt6K5ozN+xUJJJ68TjHBHnMXAS62mydew@mail.gmail.com>
<CAJQBtg=+_46_NDqYcpbf+heO4RjStvpJOuui9wgKmiEDinS9jg@mail.gmail.com>
<CAPTjJmrvUxenuBptvTDKiXptnzvLZQRhhYR_nuRTGibE5LaB3Q@mail.gmail.com>
<CAJQBtgk23N+TZ-Wce2iHwZo4pGX14gL2+k6NDre=TJ4c96wt=A@mail.gmail.com>
<CAPTjJmqxy7CdqfgX0GQDQB8C4t35rUrrch3yM_wG1jJ6rU0k5w@mail.gmail.com>
<02b201da471c$c6bafad0$5430f070$@gmail.com>
<CAJQBtgntgGc6oFqLS0nKuG8tAZT+fSA0d6on3Xw=0rHB_mANBQ@mail.gmail.com>
<CAPTjJmq2iXXuiRa0CHPddBQHm3kcoxGWW42sVAJKT9TUFxDiJw@mail.gmail.com>
 by: dn - Sun, 14 Jan 2024 22:29 UTC

On 15/01/24 10:23, Chris Angelico via Python-list wrote:
> On Mon, 15 Jan 2024 at 08:15, Left Right <olegsivokon@gmail.com> wrote:
>> Python grammar rules prevent function definition from
>> appearing in left-hand side of the head of the for loop. However, a
>> variable declaration, which is also a statement, is allowed there.
>
> What is a "variable declaration" in Python? Please elaborate.

We may be in danger of disappearing down an unintended 'rabbit hole'
with this side-discussion (he says, with graceful under-statement).

The basic challenge came from my earlier (and blasé) repetition of the
Python refrain "everything in Python is an object". Which led to:

<<<
For example, you may say "functions in Python are
objects", but you cannot put a function definition in the head of the
for loop clause.
>>>

Which is logical - to some degree, and in-isolation.

for def a_function( etc )... in iterable/iterator:

does not make sense. The 'head' (a more generic name, where Python says
"target_list", that refines down to 'something which can identify the
generated-value'.

So, no, there's an "everything" which (might be) an object but which
cannot be used in that scenario.

Two "howevers":

However, instead of looking at the narrow clause, (third comment about
wording not being taken as an whole!!!)* the full quotation was:

<<<
In Python, everything is an object. As long as the LHS is a legal-object
which makes sense for the situation, it can be used.
>>>

Context!

However, from the docs: "A function definition defines a user-defined
function object (see section The standard type hierarchy)". Accordingly,
is a function-definition an object? No! It defines an object.

That said, does anyone think that something like:

for a_function( etc ) in iterable/iterator:

is acceptable?
- see both Python definition and (full-)quotation.

I've not come-across a language which does allow such - YMMV/mea culpa;
and am struggling to see how it could possibly be useful.

In-turn, how this discussion could become profitable...

* Looking at the correspondent's email-address (cf 'handle') - and as an
unfair stereotype, raises the question of issues related to (English)
language-skills - which, arrogantly implies/assumes that native
English-speakers are all highly-capable. (?) A negative-interpretation
is to note his apparent intelligence, but wonder if failing to represent
others' comments fairly is deliberate, or carelessness. Is there an
irony in behaving/failing in such, whilst attempting to hold Python's
structure to some golden-ideal?

Web.Refs:
https://docs.python.org/3/reference/compound_stmts.html#the-for-statement
https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-target_list
https://docs.python.org/3/reference/compound_stmts.html#function-definitions

--
Regards,
=dn

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor