Re: Extract lines from file, add to new files

2024-01-14 Thread Greg Ewing via Python-list
On 15/01/24 1:28 am, Left Right wrote: Python isn't a context-free language, so the grammar that is used to describe it doesn't actually describe the language Very few languages have a formal grammar that *fully* describes the set of strings that constitute valid programs, including all the

Re: Extract lines from file, add to new files

2024-01-14 Thread Greg Ewing via Python-list
On 13/01/24 11:34 pm, Left Right wrote: To make this shorter, Python allows: for in ... : ... Um, no, it doesn't. An assignment target is not, on its own, a statement. It's hard to make sense of what you're saying. You seem to be surprised by the fact that Python doesn't require variables

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 14:45, Chris Angelico wrote: On Mon, 15 Jan 2024 at 12:42, dn via Python-list wrote: On 15/01/24 14:33, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 12:12, dn via Python-list wrote: Here's another witticism I'll often toss at trainees (in many languages, and

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 12:42, dn via Python-list wrote: > > On 15/01/24 14:33, Chris Angelico via Python-list wrote: > > On Mon, 15 Jan 2024 at 12:12, dn via Python-list > > wrote: > >> Here's another witticism I'll often toss at trainees (in many languages, > >> and especially in UX): just

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 14:33, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 12:12, dn via Python-list wrote: Here's another witticism I'll often toss at trainees (in many languages, and especially in UX): just because we can do it, doesn't make it a good idea! Programming. We were so

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 12:12, dn via Python-list wrote: > Here's another witticism I'll often toss at trainees (in many languages, > and especially in UX): just because we can do it, doesn't make it a good > idea! > Programming. We were so busy with whether we COULD that we didn't stop to think

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 11:47, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 09:40, dn via Python-list wrote: The basic challenge came from my earlier (and blasé) repetition of the Python refrain "everything in Python is an object". Which led to: ... So, no, there's an "everything" which

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 08:06, AVI GROSS via Python-list wrote: ...> You provided a way to create an anonymous function and that was not enough. I wonder if you could throw in the new := walrus operator to similarly make a named lambda function in a similar way. Why would @Chris have anything to do with

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 01:28, Left Right wrote: Second time to ameliorate wording-dispute in this thread! The original phrase was: "[modified] BNF". Some of us have worked with various forms and evolutions of BNF since back in the days of COBOL-60 proposals, and know it when we see it! OK, here are the

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Mike Dewhirst via Python-list
In Windows the provided methods for running complex command lines are either a batch file or a shortcut.Someone very kindly pointed out to me in this thread that there is a PEP for py.exe. I don't use py.exe originally because I didn't trust it believing it was a new-fangled Microsoft trick. I

RE: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
Whoa, Олег Сивоконь! I do not understand any arguments about whether comments are, or are not an object. From one perspective, python comments have even less meaning than whitespace and simply do not exist. I mean once a naked "#" is seen, the rest of that line is effectively discarded by the

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 09:40, dn via Python-list 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

RE: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
Straight Ahead, on average, I am not sure what your beef is as apparently it is always something else than some others assumed. If your point is that you want consistency, sure that would be nice. But maybe part of the inconsistency I am not sure you mean is an artifact of the language. There

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 15/01/24 10:23, Chris Angelico via Python-list wrote: On Mon, 15 Jan 2024 at 08:15, Left Right 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.

Re: Extract lines from file, add to new files

2024-01-14 Thread Left Right via Python-list
> You said function. I made a function. You said "head of a for loop > clause". I put it there. Problem was underspecified. I also wrote a lot of letters, if you combine them very liberally, without any regard to the order in which they were written or the context in which they were used, you may

Re: Extract lines from file, add to new files

2024-01-14 Thread Left Right via Python-list
> Second time to ameliorate wording-dispute in this thread! The original > phrase was: "[modified] BNF". Some of us have worked with various forms > and evolutions of BNF since back in the days of COBOL-60 proposals, and > know it when we see it! OK, here are the conceptual differences between

Re: Extract lines from file, add to new files

2024-01-14 Thread dn via Python-list
On 14/01/24 16:48, Chris Angelico wrote: On Sun, 14 Jan 2024 at 14:43, dn via Python-list wrote: Similarly, whilst we could write: a, b, c = 1, 2, 3 I would only do this when it aligns particularly well with the algorithm being implemented. For example, you could start a Fibonacci

Re: Extract lines from file, add to new files

2024-01-14 Thread Left Right via Python-list
> What do you mean? > > for x in lambda: ...: > ... > > Perfectly grammatical. 1. You put the lambda definition in the wrong place (it should be in the left-hand side, or as Python calls it "star_targets", but you put it into "star_expressions", which would be where the right-hand side is drawn

Re: Extract lines from file, add to new files

2024-01-14 Thread Left Right via Python-list
> What do you mean by this? Most languages I've worked with allow > variables to be initialized with arbitrary expressions, and a lot of > languages allow narrowly-scoped variables. I'm talking about the *left* hand side of the assignment, not the right hand side. Initialization with arbitrary

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 08:15, Left Right 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

RE: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
Chris, It gets frustrating when people demand too much when strictly speaking, it is not really needed or may cause new problems. How often do you really think anyone out there NEEDS to define a function in the context mentioned? You provided a way to create an anonymous function and that was

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Thomas Passin via Python-list
On 1/14/2024 8:54 AM, Thomas Passin via Python-list wrote: On 1/14/2024 7:48 AM, Sibylle Koczian via Python-list wrote: Am 09.01.2024 um 12:36 schrieb Barry Scott via Python-list: On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list wrote: Oh, and the two Windows and Python versions

RE: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
It can be worth considering why a language is designed or altered in certain ways to see if there was a tradeoff that made it seem worthwhile or easier than some other choice. Python grew and there was regular pressure to add keywords which might break existing programs. So, yes, sometimes, a

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Thomas Passin via Python-list
On 1/14/2024 7:48 AM, Sibylle Koczian via Python-list wrote: Am 09.01.2024 um 12:36 schrieb Barry Scott via Python-list: On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list wrote: Oh, and the two Windows and Python versions are on two different computers. Will remove the "/env"

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 00:27, Left Right wrote: > > > What do you mean? > > > > for x in lambda: ...: > > ... > > > > Perfectly grammatical. > > 1. You put the lambda definition in the wrong place (it should be in > the left-hand side, or as Python calls it "star_targets", but you put > it into

Re: Python 3.12.1, Windows 11: shebang line #!/usr/bin/env python3 doesn't work any more

2024-01-14 Thread Sibylle Koczian via Python-list
Am 09.01.2024 um 12:36 schrieb Barry Scott via Python-list: On 7 Jan 2024, at 15:09, Sibylle Koczian via Python-list wrote: Oh, and the two Windows and Python versions are on two different computers. Will remove the "/env" from my shebang lines, even if I don't understand what's

Re: Extract lines from file, add to new files

2024-01-14 Thread Chris Angelico via Python-list
On Sun, 14 Jan 2024 at 23:28, Left Right wrote: > Having worked with a bunch of different grammar languages, the one > used for Python isn't a recognizable BNF derivative. That might possibly be because it isn't? It's not BNF. It's PEG. Or are you a long way behind the times? > For example, you