Re: Extract lines from file, add to new files

2024-02-04 Thread dn via Python-list
On 4/02/24 13:20, avi.e.gr...@gmail.com wrote: Dave, You and I have had some experience in teaching or tutoring others and I think it fair to say our motivation is closer to teaching someone how they can fish for themselves rather than just handing them a fully-cooked fish. Which may push

RE: Extract lines from file, add to new files

2024-02-03 Thread AVI GROSS via Python-list
, February 3, 2024 5:02 PM To: python-list@python.org Subject: Re: Extract lines from file, add to new files Every trainer, in any field, has to deal with these problems - all the time, and over-and-over. On 4/02/24 06:58, Thomas Passin via Python-list wrote: > In my view this whole thread bec

Re: Extract lines from file, add to new files

2024-02-03 Thread Thomas Passin via Python-list
On 2/3/2024 5:02 PM, dn via Python-list wrote: Every trainer, in any field, has to deal with these problems - all the time, and over-and-over. On 4/02/24 06:58, Thomas Passin via Python-list wrote: In my view this whole thread became murky and complicated because the OP did not write down

Re: Extract lines from file, add to new files

2024-02-03 Thread dn via Python-list
Every trainer, in any field, has to deal with these problems - all the time, and over-and-over. On 4/02/24 06:58, Thomas Passin via Python-list wrote: In my view this whole thread became murky and complicated because the OP did not write down the requirements for the program.  Requirements

RE: Extract lines from file, add to new files

2024-02-03 Thread AVI GROSS via Python-list
-- From: Python-list On Behalf Of Thomas Passin via Python-list Sent: Saturday, February 3, 2024 12:59 PM To: python-list@python.org Subject: Re: Extract lines from file, add to new files In my view this whole thread became murky and complicated because the OP did not write down the requirem

Re: Extract lines from file, add to new files

2024-02-03 Thread Mats Wichmann via Python-list
On 2/3/24 10:58, Thomas Passin via Python-list wrote: In my view this whole thread became murky and complicated because the OP did not write down the requirements for the program.  Requirements are needed to communicate with other people.  An individual may not need to actually write down the

Re: Extract lines from file, add to new files

2024-02-03 Thread Thomas Passin via Python-list
Of Thomas Passin via Python-list Sent: Wednesday, January 31, 2024 7:25 AM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On 1/30/2024 11:25 PM, avi.e.gr...@gmail.com wrote: Thomas, on some points we may see it differently. I'm mostly going by what the OP

RE: Extract lines from file, add to new files

2024-02-03 Thread AVI GROSS via Python-list
and maybe garbage collection was not automatic, ... -Original Message- From: Python-list On Behalf Of Thomas Passin via Python-list Sent: Wednesday, January 31, 2024 7:25 AM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On 1/30/2024 11:25 PM, avi.e.gr

RE: Extract lines from file, add to new files

2024-02-03 Thread AVI GROSS via Python-list
:36 AM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On 1/31/2024 9:05 AM, Rich Shepard via Python-list wrote: > On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: > >> If I had a script that's been working for 30 years, I'd probably just u

Re: Extract lines from file, add to new files

2024-01-31 Thread Thomas Passin via Python-list
On 1/31/2024 9:05 AM, Rich Shepard via Python-list wrote: On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: If I had a script that's been working for 30 years, I'd probably just use Python to do the personalizing and let the rest of the bash script do the rest, like it always has. The

Re: Extract lines from file, add to new files

2024-01-31 Thread Rich Shepard via Python-list
On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: If I had a script that's been working for 30 years, I'd probably just use Python to do the personalizing and let the rest of the bash script do the rest, like it always has. The Python program would pipe or send the personalized messages

Re: Extract lines from file, add to new files

2024-01-31 Thread Thomas Passin via Python-list
Subject: Re: Extract lines from file, add to new files On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote: On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: Fine, my toy example will still be applicable. But, you know, you haven't told us enough to give you help. Do you want

RE: Extract lines from file, add to new files

2024-01-30 Thread AVI GROSS via Python-list
Python-list Sent: Tuesday, January 30, 2024 10:37 PM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote: > On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: > >> Fine, my toy exampl

Re: Extract lines from file, add to new files

2024-01-30 Thread Thomas Passin via Python-list
On 1/30/2024 12:21 PM, Rich Shepard via Python-list wrote: On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: Fine, my toy example will still be applicable. But, you know, you haven't told us enough to give you help. Do you want to replace text from values in a file? That's been

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

2024-01-30 Thread Mats Wichmann via Python-list
On 1/30/24 14:46, AVI GROSS via Python-list wrote: Rich, You may want to broaden your perspective a bit when people make suggestions. Karsten did not spell out a full design and should not need to. But consider this as a scenario. You want to send (almost) the same message to one or more

RE: Aw: Re: Extract lines from file, add to new files

2024-01-30 Thread AVI GROSS via Python-list
Subject: Re: Aw: Re: Extract lines from file, add to new files On Tue, 30 Jan 2024, Karsten Hilbert wrote: > Why not foxus on just the part you think you are better off using python, > namely personalization ? > > Create personalized files and send them with your trusted mailx solution ? K

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

2024-01-30 Thread Karsten Hilbert via Python-list
> On Tue, 30 Jan 2024, Karsten Hilbert wrote: > > > It doesn't need to. It just sends the (pre-personalized-by-Python) mail > > files. > > Karsten, > > In which case, I might as well have Python format and send the messages. :-) Certainly. But it seems you are wrestling with Python. Might as

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

2024-01-30 Thread Rich Shepard via Python-list
On Tue, 30 Jan 2024, Karsten Hilbert wrote: It doesn't need to. It just sends the (pre-personalized-by-Python) mail files. Karsten, In which case, I might as well have Python format and send the messages. :-) Regards, Rich -- https://mail.python.org/mailman/listinfo/python-list

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

2024-01-30 Thread Karsten Hilbert via Python-list
> > Why not foxus on just the part you think you are better off using python, > > namely personalization ? > > > > Create personalized files and send them with your trusted mailx solution ? > > Karsten, > > Too much time. And while mailx accepts the '-a' option for attachments but > has none for

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

2024-01-30 Thread Rich Shepard via Python-list
On Tue, 30 Jan 2024, Karsten Hilbert wrote: Why not foxus on just the part you think you are better off using python, namely personalization ? Create personalized files and send them with your trusted mailx solution ? Karsten, Too much time. And while mailx accepts the '-a' option for

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

2024-01-30 Thread Karsten Hilbert via Python-list
> For 30 years I've used a bash script using mailx to send messages to a list > of recipients. They have no salutation to personalize each one. Since I want > to add that personalized salutation I decided to write a python script to > replace the bash script. Why not foxus on just the part you

RE: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list
On Tue, 30 Jan 2024, AVI GROSS via Python-list wrote: But seriously, the OP, AKA Rich, is making clear that he is making a tool for his own use. It sounds like he wants to maintain a data repository of his own with some info about his clients and then have the ability to specify a name and pop

Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list
On Tue, 30 Jan 2024, Thomas Passin via Python-list wrote: Fine, my toy example will still be applicable. But, you know, you haven't told us enough to give you help. Do you want to replace text from values in a file? That's been covered. Do you want to send the messages using those libraries?

RE: Extract lines from file, add to new files

2024-01-30 Thread AVI GROSS via Python-list
I deleted the contents of the message so I can avoid both of the deadly sins of top posting and bottom posting and chance committing the sin of replying without any context. Of course, I am only replying to Jon wishing a real or feigned good luck to the OP. But seriously, the OP, AKA Rich, is

Re: Extract lines from file, add to new files

2024-01-30 Thread Thomas Passin via Python-list
On 1/30/2024 8:37 AM, Rich Shepard via Python-list wrote: On Mon, 29 Jan 2024, Thomas Passin via Python-list wrote: If you aren't going to use one or another existing template system, perhaps the easiest is to use unique strings in the message file. For example: Dear __##so-and-so##__:  

Re: Extract lines from file, add to new files

2024-01-30 Thread Larry Martell via Python-list
On Tue, Jan 30, 2024 at 1:13 AM AVI GROSS via Python-list wrote: > > It can be quite frustrating figuring out what someone wants, Grant, > especially when they just change it. > > It is worse when instead of starting a new thread with an appropriate > subject line, it continues and old one that

Re: Extract lines from file, add to new files

2024-01-30 Thread Rich Shepard via Python-list
On Mon, 29 Jan 2024, Thomas Passin via Python-list wrote: If you aren't going to use one or another existing template system, perhaps the easiest is to use unique strings in the message file. For example: Dear __##so-and-so##__: Please don't write this message off as mere spam.

RE: Extract lines from file, add to new files

2024-01-29 Thread AVI GROSS via Python-list
:54 PM To: python-list@python.org Subject: Re: Extract lines from file, add to new files On 2024-01-29, Rich Shepard via Python-list wrote: > On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote: > >> No, I hadn't ... but I am reading it now. > > Perhaps I missed the answer t

Re: Extract lines from file, add to new files

2024-01-29 Thread Thomas Passin via Python-list
On 1/29/2024 11:15 AM, Rich Shepard via Python-list wrote: For my use 1) the salutation and email address (always with an '@') are sequential and 2) I'm developing the script to extract both from the same file. I've looked at my Python books "Python Crash Course," "Effective Python," and

Re: Extract lines from file, add to new files

2024-01-29 Thread Grant Edwards via Python-list
On 2024-01-29, Rich Shepard via Python-list wrote: > On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote: > >> No, I hadn't ... but I am reading it now. > > Perhaps I missed the answer to my question when reading the io module. It > explains how to open/write/read files of text and binary

Re: Extract lines from file, add to new files

2024-01-29 Thread dn via Python-list
On 30/01/24 05:15, Rich Shepard via Python-list wrote: On Fri, 12 Jan 2024, Rich Shepard via Python-list wrote: For my use 1) the salutation and email address (always with an '@') are sequential and 2) I'm developing the script to extract both from the same file. I've looked at my Python

RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list
On Mon, 29 Jan 2024, avi.e.gr...@gmail.com wrote: There are several general solutions that may apply. Some involve reading in both files into data structures and perhaps linking them together in some way such as a data.frame or binary tree. You can then process individual request in memory/

RE: Extract lines from file, add to new files

2024-01-29 Thread AVI GROSS via Python-list
: Extract lines from file, add to new files On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote: > No, I hadn't ... but I am reading it now. Perhaps I missed the answer to my question when reading the io module. It explains how to open/write/read files of text and binary data, not pass

RE: Extract lines from file, add to new files [RESOLVED]

2024-01-29 Thread Rich Shepard via Python-list
On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote: I'll keep searching for a solution. IIRC, someone here pointed me to and I forgot about it ... until now. Regards, Rich -- https://mail.python.org/mailman/listinfo/python-list

RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list
On Mon, 29 Jan 2024, Rich Shepard via Python-list wrote: No, I hadn't ... but I am reading it now. Perhaps I missed the answer to my question when reading the io module. It explains how to open/write/read files of text and binary data, not passing a variable's value from one file to a

RE: Extract lines from file, add to new files

2024-01-29 Thread Dieter Maurer via Python-list
Rich Shepard wrote at 2024-1-29 08:15 -0800: > ... >If this explanation is not sufficiently clear I'll re-write it. :-) Have you read "https://docs.python.org/3/library/io.html#module-io;? -- https://mail.python.org/mailman/listinfo/python-list

RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list
On Mon, 29 Jan 2024, dieter.mau...@online.de wrote: Have you read "https://docs.python.org/3/library/io.html#module-io;? Dieter, No, I hadn't ... but I am reading it now. Many thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list

RE: Extract lines from file, add to new files

2024-01-29 Thread Rich Shepard via Python-list
On Fri, 12 Jan 2024, Rich Shepard via Python-list wrote: For my use 1) the salutation and email address (always with an '@') are sequential and 2) I'm developing the script to extract both from the same file. I've looked at my Python books "Python Crash Course," "Effective Python," and

Re: Extract lines from file, add to new files

2024-01-15 Thread Antoon Pardon via Python-list
Op 14/01/2024 om 13:28 schreef Left Right via Python-list: Python isn't a context-free language, so the grammar that is used to describe it doesn't actually describe the language... so, it's a "pretend grammar" that ignores indentation. No it doesn't. Here is the definition of a block, it

Re: Extract lines from file, add to new files

2024-01-15 Thread dn via Python-list
On 15/01/24 21:13, Greg Ewing via Python-list wrote: On 15/01/24 1:54 pm, dn wrote: Soon after, Wirth simplified rather than expanded, and developed Pascal. Before Pascal there was Algol-W, which Wirth invented as a rebellion against how complicated Algol 68 was becoming. When I first saw

Re: Extract lines from file, add to new files

2024-01-15 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 19:26, Greg Ewing via Python-list wrote: > > On 15/01/24 9:07 pm, Chris Angelico wrote: > > The grammar *can't* specify everything. If it did, it would have to > > have rules for combining individual letters into a NAME and individual > > characters into a string literal. >

Re: Extract lines from file, add to new files

2024-01-15 Thread Greg Ewing via Python-list
On 15/01/24 9:07 pm, Chris Angelico wrote: The grammar *can't* specify everything. If it did, it would have to have rules for combining individual letters into a NAME and individual characters into a string literal. The lexical level of a grammar can be, and often is, described formally using

Re: Extract lines from file, add to new files

2024-01-15 Thread Greg Ewing via Python-list
On 15/01/24 1:54 pm, dn wrote: Soon after, Wirth simplified rather than expanded, and developed Pascal. Before Pascal there was Algol-W, which Wirth invented as a rebellion against how complicated Algol 68 was becoming. When I first saw this I was stunned, then attracted to its simplicity,

Re: Extract lines from file, add to new files

2024-01-15 Thread Chris Angelico via Python-list
On Mon, 15 Jan 2024 at 18:56, Greg Ewing via Python-list wrote: > > 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*

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: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
thon-list On Behalf Of Left Right via Python-list Sent: Sunday, January 14, 2024 7:28 AM To: Chris Angelico Cc: python-list@python.org Subject: Re: Extract lines from file, add to new files > Second time to ameliorate wording-dispute in this thread! The original > phrase was: "[modifie

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
avi.e.gr...@gmail.com Cc: Chris Angelico ; python-list@python.org Subject: Re: Extract lines from file, add to new files > 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 y

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
@python.org Subject: Re: Extract lines from file, add to new files 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 wron

RE: Extract lines from file, add to new files

2024-01-14 Thread AVI GROSS via Python-list
f Of Chris Angelico via Python-list Sent: Sunday, January 14, 2024 7:32 AM To: python-list@python.org Subject: Re: Extract lines from file, add to new files 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'

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

Re: Extract lines from file, add to new files

2024-01-13 Thread Chris Angelico via Python-list
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 evaluator with "a, b = 0, 1". Otherwise,

Re: Extract lines from file, add to new files

2024-01-13 Thread dn via Python-list
On 13/01/24 00:11, Left Right via Python-list wrote: To people discussing BNF: The grammar language Python uses is *very* far from BNF. It's more similar to PEG, but even then it's still quite far. Python's grammar is just its own thing, which makes it harder to read, if you are already

Re: Extract lines from file, add to new files

2024-01-13 Thread dn via Python-list
On 12/01/24 08:53, Rich Shepard via Python-list wrote: On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. (sitting in a meeting with little to

Re: Extract lines from file, add to new files

2024-01-13 Thread Greg Ewing via Python-list
On 13/01/24 3:14 pm, Chris Angelico wrote: On Sat, 13 Jan 2024 at 13:11, Left Right via Python-list wrote: Very few languages allow arbitrary complex expressions in the same place they allow variable introduction. What do you mean by this? Most languages I've worked with allow variables

Re: Extract lines from file, add to new files

2024-01-13 Thread Greg Ewing via Python-list
On 13/01/24 1:45 pm, Left Right wrote: I use the term "destructuring" in the same way Hyperspec uses it. It's not a Python term. I don't know what you call the same thing in Python. I'm not sure what you understand from it. I thought you meant what is usually called "unpacking" in Python. I

Re: Extract lines from file, add to new files

2024-01-13 Thread Dan Sommers via Python-list
On 2024-01-13 at 11:34:29 +0100, Left Right wrote: > > The Python term, at least colloquially, is "tuple unpacking." That quote is from me. Please do preserve attributions. > Well, why use colloquialism if there's a language specification? Also, > there weren't any tuples used in my example,

Re: Extract lines from file, add to new files

2024-01-12 Thread Dan Sommers via Python-list
On 2024-01-13 at 02:02:39 +0100, Left Right via Python-list wrote: > Actually, after some Web search. I think, based on this: > https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-augtarget > that in Python you call this "augmented assignment target". The term >

Re: Extract lines from file, add to new files

2024-01-12 Thread Chris Angelico via Python-list
On Sat, 13 Jan 2024 at 13:11, Left Right via Python-list wrote: > > Very few > languages allow arbitrary complex expressions in the same place they > allow variable introduction. What do you mean by this? Most languages I've worked with allow variables to be initialized with arbitrary

Re: Extract lines from file, add to new files

2024-01-12 Thread Left Right via Python-list
Actually, after some Web search. I think, based on this: https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-augtarget that in Python you call this "augmented assignment target". The term isn't in the glossary, but so are many others. On Sat, Jan 13, 2024 at 1:45 

Re: Extract lines from file, add to new files

2024-01-12 Thread Left Right via Python-list
> surprising for me: Surprise is subjective, it's based on personal experience. Very few languages allow arbitrary complex expressions in the same place they allow variable introduction. The fact that "i" is not defined is irrelevant to this example. Most programmers who haven't memorized Python

Re: Extract lines from file, add to new files

2024-01-12 Thread Greg Ewing via Python-list
On 13/01/24 12:11 am, Left Right wrote: x = [...] for x[i] in x: print(i) I suspect you've misremembered something, because this doesn't do anything surprising for me: >>> x = [1, 2, 3] >>> for x[i] in x: print(i) ... Traceback (most recent call last): File "", line 1, in

Re: Extract lines from file, add to new files

2024-01-12 Thread Left Right via Python-list
To people discussing BNF: The grammar language Python uses is *very* far from BNF. It's more similar to PEG, but even then it's still quite far. Python's grammar is just its own thing, which makes it harder to read, if you are already familiar with other more popular formats. I've also found

RE: Extract lines from file, add to new files

2024-01-12 Thread Rich Shepard via Python-list
On Fri, 12 Jan 2024, AVI GROSS via Python-list wrote: But is the solution a good one for some purpose? The two output files may end up being out of sync for all kinds of reasons. One of many "errors" can happen if multiple lines in a row do not have an "@" or a person's name does, for example.

RE: Extract lines from file, add to new files

2024-01-12 Thread AVI GROSS via Python-list
ne in a vectoried manner might be faster than an array of objects, but is more often a sign of poor code. -Original Message- From: Python-list On Behalf Of Grizzy Adams via Python-list Sent: Friday, January 12, 2024 1:59 AM To: Rich Shepard via Python-list ; Rich Shepard Subject: Re: E

Re: Extract lines from file, add to new files

2024-01-11 Thread Grizzy Adams via Python-list
Thursday, January 11, 2024 at 10:44, Rich Shepard via Python-list wrote: Re: Extract lines from file, add to (at least in part) >On Thu, 11 Jan 2024, MRAB via Python-list wrote: >> From the look of it: >> 1. If the line is empty, ignore it. >> 2. If the line contains "@", it's an email address.

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 12:56, Chris Angelico via Python-list wrote: On Fri, 12 Jan 2024 at 08:56, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: When you jump immediately to "this is a bug", all you do is make

Re: Extract lines from file, add to new files

2024-01-11 Thread Chris Angelico via Python-list
On Fri, 12 Jan 2024 at 08:56, Left Right via Python-list wrote: > > By the way, in an attempt to golf this problem, I discovered this, > which seems like a parser problem: When you jump immediately to "this is a bug", all you do is make yourself look like an idiot. Unsurprisingly, this is NOT a

Re: Extract lines from file, add to new files

2024-01-11 Thread dn via Python-list
On 12/01/24 10:33, Left Right via Python-list wrote: By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: This is what Python tells me about its grammar: with_stmt: | 'with' '(' ','.with_item+ ','? ')' ':' block | 'with' ','.with_item+

Re: Extract lines from file, add to new files

2024-01-11 Thread Left Right via Python-list
Ah, nevermind. I need to be more careful, there isn't an "'as' star_target" after the first rule. On Thu, Jan 11, 2024 at 10:33 PM Left Right wrote: > > By the way, in an attempt to golf this problem, I discovered this, > which seems like a parser problem: > > This is what Python tells me about

Re: Extract lines from file, add to new files

2024-01-11 Thread Left Right via Python-list
By the way, in an attempt to golf this problem, I discovered this, which seems like a parser problem: This is what Python tells me about its grammar: with_stmt: | 'with' '(' ','.with_item+ ','? ')' ':' block | 'with' ','.with_item+ ':' [TYPE_COMMENT] block | ASYNC 'with' '('

Re: Extract lines from file, add to new files

2024-01-11 Thread Thomas Passin via Python-list
On 1/11/2024 1:27 PM, MRAB via Python-list wrote: On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two

Re: Extract lines from file, add to new files

2024-01-11 Thread Mirko via Python-list
Am 11.01.24 um 20:53 schrieb Rich Shepard via Python-list: On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. Thank you, Rich awk '/@/ {print

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, Piergiorgio Sartor via Python-list wrote: Why not to use bash script for all? Piergiorgio, That's certainly a possibility, and may well be better than python for this task. Thank you, Rich -- https://mail.python.org/mailman/listinfo/python-list

Re: Extract lines from file, add to new files

2024-01-11 Thread Piergiorgio Sartor via Python-list
On 11/01/2024 19.08, Rich Shepard wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An example of the

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, Mats Wichmann via Python-list wrote: 4. Don't assume it's going to be "plain text" if the email info is harvested from external sources (like incoming emails) - you'll end up stumbling over a 誰かのユーザー from somewhere. Process as bytes, or be really careful about which

Re: Extract lines from file, add to new files

2024-01-11 Thread Mats Wichmann via Python-list
On 1/11/24 11:27, MRAB via Python-list wrote: On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two

Re: Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
On Thu, 11 Jan 2024, MRAB via Python-list wrote: From the look of it: 1. If the line is empty, ignore it. 2. If the line contains "@", it's an email address. 3. Otherwise, it's a name. MRAB, Thanks. I'll take it from here. Regards, Rich --

Re: Extract lines from file, add to new files

2024-01-11 Thread MRAB via Python-list
On 2024-01-11 18:08, Rich Shepard via Python-list wrote: It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An

Extract lines from file, add to new files

2024-01-11 Thread Rich Shepard via Python-list
It's been several years since I've needed to write a python script so I'm asking for advice to get me started with a brief script to separate names and email addresses in one file into two separate files: salutation.txt and emails.txt. An example of the input file: Calvin cal...@example.com