Extract lines from file, add to new files

Chris Angelico rosuav at gmail.com
Sun Jan 14 17:47:32 EST 2024


On Mon, 15 Jan 2024 at 09:40, dn via Python-list <python-list at python.org> wrote:
> 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.

More accurately, every VALUE in Python is an object. This does not
mean that syntax is an object. Very few languages would say that every
single grammatical element is a value.

Yes, it's sloppy to say "everything" is an object, but it's also
rather nonintuitive to claim that, therefore, syntax elements are all
objects. It's like claiming that everything that this dealership sells
is a car (or "everything in this dealership is a car"), and therefore
the dealership's name must itself be a car.

> 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.

You could do something close to that:

for a_function(etc)[0] in iterable: ...

because an assignment target can contain an arbitrary expression
followed by the subscript.

> * 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?

Seems likely.

ChrisA


More information about the Python-list mailing list