Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Rick Johnson writes: >> There is now also a line that starts with: PCH_CPU_TEMP: >> And I do not want that one. > > Yes. But be aware, that while the `str.startswith(target)` > method is indeed more efficient than a more generalized > "inclusion test", if the target

Re: How to use a regexp here

2017-12-08 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line.

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Neil Cerutti writes: > On 2017-12-04, Cecil Westerhof wrote: >> Joel Goldstick writes: >> >>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >>> wrote: >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:

Re: How to use a regexp here

2017-12-08 Thread Neil Cerutti
On 2017-12-04, Cecil Westerhof wrote: > Joel Goldstick writes: > >> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >> wrote: >> >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >>> I have a script that was running perfectly

Re: How to use a regexp here

2017-12-08 Thread Terry Reedy
On 12/4/2017 11:14 AM, Ned Batchelder wrote: > On 12/4/17 9:13 AM, Rick Johnson wrote: >> Perhaps it's not politically correct for me to say this, but >> i've never been one who cared much about political >> correctness, so i'm just going to say it... > > Cecil, feel free to ignore the rest of

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: > Perhaps it's not politically correct for me to say this, but > i've never been one who cared much about political > correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.â His messages are famous for their

Re: How to use a regexp here

2017-12-08 Thread Joel Goldstick
On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder wrote: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: > >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed,

Re: How to use a regexp here

2017-12-08 Thread Rick Johnson
Cecil Westerhof wrote: > Joel Goldstick writes: [...] > > I like Ned's clear answer, but I'm wondering why the > > original code would fail because the substring is at the > > start of the line, since 'in' would still be true no > > matter where the desired string is placed. It would be > >

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Joel Goldstick writes: > On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder > wrote: > >> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> >>> I have a script that was running perfectly for some time. It uses: >>> array = [elem for elem in output

Re: How to use a regexp here

2017-12-08 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line. What would be the best way

Re: How to use a regexp here

2017-12-08 Thread Cecil Westerhof
Ned Batchelder writes: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed, I have to check for CPU_TEMP at

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Neil Cerutti writes: > On 2017-12-04, Cecil Westerhof wrote: >> Joel Goldstick writes: >> >>> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >>> wrote: >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote:

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Rick Johnson writes: >> There is now also a line that starts with: PCH_CPU_TEMP: >> And I do not want that one. > > Yes. But be aware, that while the `str.startswith(target)` > method is indeed more efficient than a more generalized > "inclusion test", if the target

Re: How to use a regexp here

2017-12-04 Thread Neil Cerutti
On 2017-12-04, Cecil Westerhof wrote: > Joel Goldstick writes: > >> On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder >> wrote: >> >>> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >>> I have a script that was running perfectly

Re: How to use a regexp here

2017-12-04 Thread Terry Reedy
On 12/4/2017 11:14 AM, Ned Batchelder wrote: On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 9:13 AM, Rick Johnson wrote: Perhaps it's not politically correct for me to say this, but i've never been one who cared much about political correctness, so i'm just going to say it... Cecil, feel free to ignore the rest of Rick's message.  His messages are famous for their

Re: How to use a regexp here

2017-12-04 Thread Rick Johnson
Cecil Westerhof wrote: > Joel Goldstick writes: [...] > > I like Ned's clear answer, but I'm wondering why the > > original code would fail because the substring is at the > > start of the line, since 'in' would still be true no > > matter where the desired string is placed. It would be > >

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Joel Goldstick writes: > On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder > wrote: > >> On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> >>> I have a script that was running perfectly for some time. It uses: >>> array = [elem for elem in output

Re: How to use a regexp here

2017-12-04 Thread Cecil Westerhof
Ned Batchelder writes: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed, I have to check for CPU_TEMP at

Re: How to use a regexp here

2017-12-04 Thread Joel Goldstick
On Mon, Dec 4, 2017 at 5:21 AM, Ned Batchelder wrote: > On 12/4/17 4:36 AM, Cecil Westerhof wrote: > >> I have a script that was running perfectly for some time. It uses: >> array = [elem for elem in output if 'CPU_TEMP' in elem] >> >> But because output has changed,

Re: How to use a regexp here

2017-12-04 Thread Ned Batchelder
On 12/4/17 4:36 AM, Cecil Westerhof wrote: I have a script that was running perfectly for some time. It uses: array = [elem for elem in output if 'CPU_TEMP' in elem] But because output has changed, I have to check for CPU_TEMP at the beginning of the line. What would be the best way to

Re: How to use a regexp here

2017-12-04 Thread breamoreboy
On Monday, December 4, 2017 at 9:44:27 AM UTC, Cecil Westerhof wrote: > I have a script that was running perfectly for some time. It uses: > array = [elem for elem in output if 'CPU_TEMP' in elem] > > But because output has changed, I have to check for CPU_TEMP at the > beginning of the line.