On 2023-03-02, Peter J. Holzer wrote:
> [1] Personally I'd say you shouldn't use Outlook if you are reading
> mails where line breaks (or other formatting) is important, but ...
I'd shorten that to
"You shouldn't use Outlook if mail is important."
--
https://mail.python.org/mailman/listin
.
-Original Message-
From: Python-list On
Behalf Of Peter J. Holzer
Sent: Thursday, March 2, 2023 3:09 PM
To: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote:
> On 2023-02-28 15:25:05 -0500, avi.e
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote:
> On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote:
> > I had no doubt the code you ran was indented properly or it would not work.
> >
> > I am merely letting you know that somewhere in the process of copying
> > the code or the transi
On 3/1/2023 12:04 PM, Grant Edwards wrote:
On 2023-02-28, Cameron Simpson wrote:
Regexps are:
- cryptic and error prone (you can make them more readable, but the
notation is deliberately both terse and powerful, which means that
small changes can have large effects in behaviour); the "
On 2023-02-28, Cameron Simpson wrote:
> Regexps are:
> - cryptic and error prone (you can make them more readable, but the
>notation is deliberately both terse and powerful, which means that
>small changes can have large effects in behaviour); the "error prone"
>part does not mean
Of Peter J. Holzer
Sent: Tuesday, February 28, 2023 7:26 PM
To: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote:
> On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote:
> > It happens to be easy for me to
@python.org
Subject: Re: How to escape strings for re.finditer?
*** Attention: This is an external email. Use caution responding, opening
attachments or clicking on links. ***
Using str.startswith is a cool idea in this case. But is it better than regex
for performance or reliability? Regex
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote:
> On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote:
> > It happens to be easy for me to fix but I sometimes see garbled code I
> > then simply ignore.
>
> Truth to be told, that's one reason why I rarely read your mails to the
> end. Th
On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote:
> Jen,
>
>
>
> I had no doubt the code you ran was indented properly or it would not work.
>
>
>
> I am merely letting you know that somewhere in the process of copying
> the code or the transition between mailers, my version is mes
On 28Feb2023 18:57, Jen Kris wrote:
One question: several people have made suggestions other than regex
(not your terser example with regex you shown below). Is there a
reason why regex is not preferred to, for example, a list comp?
These are different things; I'm not sure a comparison is
On 2/28/2023 2:40 PM, David Raymond wrote:
With a slight tweak to the simple loop code using .find() it becomes a third
faster than the RE version though.
def using_simple_loop2(key, text):
matches = []
keyLen = len(key)
start = 0
while (foundSpot := text.find(key, start))
function that
hides the loops inside a faster environment than the interpreter.
-Original Message-
From: Python-list On
Behalf Of David Raymond
Sent: Tuesday, February 28, 2023 2:40 PM
To: python-list@python.org
Subject: RE: How to escape strings for re.finditer?
> I wrote my previ
To: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
On 2/28/2023 1:07 PM, Jen Kris wrote:
>
> Using str.startswith is a cool idea in this case. But is it better
> than regex for performance or reliability? Regex syntax is not a
> model of simplicity, but in
, February 28, 2023 12:58 PM
To: avi.e.gr...@gmail.com
Cc: 'Python List'
Subject: RE: How to escape strings for re.finditer?
The code I sent is correct, and it runs here. Maybe you received it with a
carriage return removed, but on my copy after posting, it is correct:
example = '
> I wrote my previous message before reading this. Thank you for the test you
> ran -- it answers the question of performance. You show that re.finditer is
> 30x faster, so that certainly recommends that over a simple loop, which
> introduces looping overhead.
>> def using_simple_loop(
On 2/28/2023 11:48 AM, Jon Ribbens via Python-list wrote:
On 2023-02-28, Thomas Passin wrote:
...
It is interesting, though, how pre-processing the search pattern can
improve search times if you can afford the pre-processing. Here's a
paper on rapidly finding matches when there may be up to
list On
Behalf Of Jen Kris via Python-list
Sent: Monday, February 27, 2023 8:36 PM
To: Cameron Simpson
Cc: Python List
Subject: Re: How to escape strings for re.finditer?
I haven't tested it either but it looks like it would work. But for this case
I prefer the relative simplicity o
: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
Op 28/02/2023 om 3:44 schreef Thomas Passin:
> On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote:
>> And, just for fun, since there is nothing wrong with your code, this
>> minor change is terser:
>&g
On 2/28/2023 1:07 PM, Jen Kris wrote:
Using str.startswith is a cool idea in this case. But is it better than
regex for performance or reliability? Regex syntax is not a model of
simplicity, but in my simple case it's not too difficult.
The trouble is that we don't know what your case real
On 2023-02-28, Thomas Passin wrote:
> On 2/28/2023 10:05 AM, Roel Schroeven wrote:
>> Op 28/02/2023 om 14:35 schreef Thomas Passin:
>>> On 2/28/2023 4:33 AM, Roel Schroeven wrote:
[...]
(2) Searching for a string in another string, in a performant way, is
not as simple as it first
I wrote my previous message before reading this. Thank you for the test you
ran -- it answers the question of performance. You show that re.finditer is
30x faster, so that certainly recommends that over a simple loop, which
introduces looping overhead.
Feb 28, 2023, 05:44 by li...@tompass
Using str.startswith is a cool idea in this case. But is it better than regex
for performance or reliability? Regex syntax is not a model of simplicity, but
in my simple case it's not too difficult.
Feb 27, 2023, 18:52 by li...@tompassin.net:
> On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com
s but also show
> the exact text that matched or even show some characters before and/or after
> for context.
>
>
> -Original Message-
> From: Python-list On
> Behalf Of Jen Kris via Python-list
> Sent: Monday, February 27, 2023 8:36 PM
> To: Cameron Simpson
On 2/28/2023 10:05 AM, Roel Schroeven wrote:
Op 28/02/2023 om 14:35 schreef Thomas Passin:
On 2/28/2023 4:33 AM, Roel Schroeven wrote:
[...]
(2) Searching for a string in another string, in a performant way, is
not as simple as it first appears. Your version works correctly, but
slowly. In so
Op 28/02/2023 om 14:35 schreef Thomas Passin:
On 2/28/2023 4:33 AM, Roel Schroeven wrote:
[...]
(2) Searching for a string in another string, in a performant way, is
not as simple as it first appears. Your version works correctly, but
slowly. In some situations it doesn't matter, but in other
On 2/28/2023 4:33 AM, Roel Schroeven wrote:
Op 28/02/2023 om 3:44 schreef Thomas Passin:
On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote:
And, just for fun, since there is nothing wrong with your code, this
minor change is terser:
example = 'X - abc_degree + 1 + qq + abc_degree + 1'
for ma
Op 28/02/2023 om 3:44 schreef Thomas Passin:
On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote:
And, just for fun, since there is nothing wrong with your code, this
minor change is terser:
example = 'X - abc_degree + 1 + qq + abc_degree + 1'
for match in re.finditer(re.escape('abc_degree + 1'
rting from where you left
off.
-Original Message-
From: Python-list On
Behalf Of Thomas Passin
Sent: Monday, February 27, 2023 9:44 PM
To: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote:
> And, just for fun
On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote:
And, just for fun, since there is nothing wrong with your code, this minor
change is terser:
example = 'X - abc_degree + 1 + qq + abc_degree + 1'
for match in re.finditer(re.escape('abc_degree + 1') , example):
... print(match.start(), ma
bookkeeper. In those
cases, you may want even more than offsets but also show the exact text that
matched or even show some characters before and/or after for context.
-Original Message-
From: Python-list On
Behalf Of Jen Kris via Python-list
Sent: Monday, February 27, 2023 8:36 PM
To:
tion and now you have a tool. Even
better, you can make it return whatever you want.
-Original Message-
From: Python-list On
Behalf Of Jen Kris via Python-list
Sent: Monday, February 27, 2023 7:40 PM
To: Bob van der Poel
Cc: Python List
Subject: Re: How to escape strings for re.findit
I haven't tested it either but it looks like it would work. But for this case
I prefer the relative simplicity of:
example = 'X - abc_degree + 1 + qq + abc_degree + 1'
find_string = re.escape('abc_degree + 1')
for match in re.finditer(find_string, example):
print(match.start(), match.end())
On 28Feb2023 00:57, Jen Kris wrote:
Yes, that's it. I don't know how long it would have taken to find that
detail with research through the voluminous re documentation. Thanks
very much.
You find things like this by printing out the strings you're actually
working with. Not the original s
On 28Feb2023 01:13, Jen Kris wrote:
I went to the re module because the specified string may appear more
than once in the string (in the code I'm writing).
Sure, but writing a `finditer` for plain `str` is pretty easy
(untested):
pos = 0
while True:
found = s.find(substring,
string.count() only tells me there are N instances of the string; it does not
say where they begin and end, as does re.finditer.
Feb 27, 2023, 16:20 by bobmellow...@gmail.com:
> Would string.count() work for you then?
>
> On Mon, Feb 27, 2023 at 5:16 PM Jen Kris via Python-list <>
> python-l
age-
From: Python-list On
Behalf Of Jen Kris via Python-list
Sent: Monday, February 27, 2023 7:14 PM
To: Cameron Simpson
Cc: Python List
Subject: Re: How to escape strings for re.finditer?
I went to the re module because the specified string may appear more than once
in the string
I went to the re module because the specified string may appear more than once
in the string (in the code I'm writing). For example:
a = "X - abc_degree + 1 + qq + abc_degree + 1"
b = "abc_degree + 1"
q = a.find(b)
print(q)
4
So it correctly finds the start of the first instance, but not
the backslash
breaks the match from going further.
-Original Message-
From: Python-list On
Behalf Of MRAB
Sent: Monday, February 27, 2023 6:46 PM
To: python-list@python.org
Subject: Re: How to escape strings for re.finditer?
On 2023-02-27 23:11, Jen Kris via Python-list wrote:
> When matching
Yes, that's it. I don't know how long it would have taken to find that detail
with research through the voluminous re documentation. Thanks very much.
Feb 27, 2023, 15:47 by pyt...@mrabarnett.plus.com:
> On 2023-02-27 23:11, Jen Kris via Python-list wrote:
>
>> When matching a string against
On 28Feb2023 00:11, Jen Kris wrote:
When matching a string against a longer string, where both strings have spaces
in them, we need to escape the spaces.
This works (no spaces):
import re
example = 'abcdefabcdefabcdefg'
find_string = "abc"
for match in re.finditer(find_string, example):
On 2023-02-27 23:11, Jen Kris via Python-list wrote:
When matching a string against a longer string, where both strings have spaces
in them, we need to escape the spaces.
This works (no spaces):
import re
example = 'abcdefabcdefabcdefg'
find_string = "abc"
for match in re.finditer(find_string,
41 matches
Mail list logo