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 is not _always_ at the
> beginning of the string, then your code is going to skip
> right over valid match like a round stone skipping across
> the surface of a glass-smooth lake. But if you are sure the
> target will always be at the beginning of the string, then
> it is the best choice.

Yes, I am sure it is always at the beginning of the line. (It is output from
the Linux sensors command.)

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

-- 
https://mail.python.org/mailman/listinfo/python-list


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. What would be the best way to implement this?
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Use https://docs.python.org/3/library/stdtypes.html#str.startswith instead of
the test for `in`.

--
Kindest regards.

Mark Lawrence.

-- 
https://mail.python.org/mailman/listinfo/python-list


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:

> 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 implement this?
>
>
 No need for a regex just yet:

 array = [elem for elem in output if elem.startswith('CPU_TEMP')]

 (btw, note that the result of this expression is a list, not an array, for
 future Googling.)

 --Ned.
 --
 https://mail.python.org/mailman/listinfo/python-list

>>>
>>> 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
>>> useful to see some sample data of the old data, and the new data
>>
>> There is now also a line that starts with:
>> PCH_CPU_TEMP:
>>
>> And I do not want that one.
>
> You'll probably want to include the ':' in the startswith check,
> in case someday they also add CPU_TEMP_SOMETHING:.

I already did. And to be really sure also included a space after it.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 implement this?


>>> No need for a regex just yet:
>>>
>>> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>>>
>>> (btw, note that the result of this expression is a list, not an array, for
>>> future Googling.)
>>>
>>> --Ned.
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>> 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
>> useful to see some sample data of the old data, and the new data
>
> There is now also a line that starts with:
> PCH_CPU_TEMP:
>
> And I do not want that one.

You'll probably want to include the ':' in the startswith check, in case
someday they also add CPU_TEMP_SOMETHING:.

--
Neil Cerutti

-- 
https://mail.python.org/mailman/listinfo/python-list


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 Rick's message.â  His messages are
> famous for their outrageous and/or abrasive tone, something he seems to
> revel in.â  Luckily, it's not typical of the Python community.

Or take Rick's 'rest' as a suggestion to reread Library Reference chapters 2,
3, 4 and in particular 4.7.

As for your idea of an RE, '^' matches the beginning of a line, and '$' the
end, though using .startswith, and .endswith, are easier if no other RE syntax
is needed for matching.

--
Terry Jan Reedy

-- 
https://mail.python.org/mailman/listinfo/python-list


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 outrageous and/or abrasive tone, something he seems to revel
in.â  Luckily, it's not typical of the Python community.

--Ned.

-- 
https://mail.python.org/mailman/listinfo/python-list


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, I have to check for CPU_TEMP at the
>> beginning of the line. What would be the best way to implement this?
>>
>>
> No need for a regex just yet:
>
> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>
> (btw, note that the result of this expression is a list, not an array, for
> future Googling.)
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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 useful to see
some sample data of the old data, and the new data

--
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays

-- 
https://mail.python.org/mailman/listinfo/python-list


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
> > useful to see some sample data of the old data, and the
> > new data

@Goldstick

"Inclusion testing" will return false positives when the target is part of a
larger structure (aka: word). Observe:

>>> s = "Complex is better than complicated."
>>> "plex" in s
True
>>> "om" in s
True
>>> s.count("om")
2

I'm sure you already know this, and only made the comment because you did not
have all the data, but i thought it would be good to mention for any lurkers
who may be watching.

> 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 is not
_always_ at the beginning of the string, then your code is going to skip right
over valid match like a round stone skipping across the surface of a
glass-smooth lake. But if you are sure the target will always be at the
beginning of the string, then it is the best choice.

> --
> Cecil Westerhof
> Senior Software Engineer

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

If you really are a "_Senior_ software engineer", and that title is not simply
an ego-booster bestowed by your boss to a one-person-dev-team in order to avoid
 pay raises, then i would expect more competence from someone who holds such an
 esteemed title.

And even *IF* you are only vaguely familiar with Python, and even *IF*, you
rarely use Python in your projects, i don't think it's too much to ask of a
~~Senior~~ Software Engineer that they possess the basic skills required to
peruse the Python documentation and decide which method is most appropriate for
 the situation at hand. And if you're using Python on a regular basis, then you
 should be intimately familiar with _all_ methods of each major type.

Granted, your question did "hint" about the possibility of using a regexp
(although, based on the data you have provided so far, a string method will
suffice), but i would also expect a ~~Senior~~ Software Engineer to not only be
 knowledgeable of regexps, but also know when they are a strength and when they
 are a weakness.

Now, there are one of two ways you can take this advice:

(1) You can take it as a personal attack; get all huffy
about it; drop to the floor and flail your arms and legs
like a petulant two-year-old who didn't get the toy he
wanted; and learn nothing in the process.

or

(2) You can take it as what it is -> constructive criticism;
shower me with gratitude[1]; and become a better person and
a better programmer in the process.

The choice is yours.


[1] Well, i had to sneak something in there for myself, after all, it is the
season of giving, yes? O:-)

Here comes santa claws...
Here comes santa claws...
...

-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 implement this?
>>>
>>>
>> No need for a regex just yet:
>>
>> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>>
>> (btw, note that the result of this expression is a list, not an array, for
>> future Googling.)
>>
>> --Ned.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> 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
> useful to see some sample data of the old data, and the new data

There is now also a line that starts with:
PCH_CPU_TEMP:

And I do not want that one.

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

-- 
https://mail.python.org/mailman/listinfo/python-list


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 to implement this?
>

No need for a regex just yet:

 â â â  array = [elem for elem in output if elem.startswith('CPU_TEMP')]

(btw, note that the result of this expression is a list, not an array, for
future Googling.)

--Ned.

-- 
https://mail.python.org/mailman/listinfo/python-list


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 the
>> beginning of the line. What would be the best way to implement this?
>>
>
> No need for a regex just yet:
>
> â â â  array = [elem for elem in output if elem.startswith('CPU_TEMP')]

Yes, that is it. I should have known that. :'-(

--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

-- 
https://mail.python.org/mailman/listinfo/python-list


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:

> 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 implement this?
>
>
 No need for a regex just yet:

 array = [elem for elem in output if elem.startswith('CPU_TEMP')]

 (btw, note that the result of this expression is a list, not an array, for
 future Googling.)

 --Ned.
 --
 https://mail.python.org/mailman/listinfo/python-list

>>>
>>> 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
>>> useful to see some sample data of the old data, and the new data
>>
>> There is now also a line that starts with:
>> PCH_CPU_TEMP:
>>
>> And I do not want that one.
>
> You'll probably want to include the ':' in the startswith check,
> in case someday they also add CPU_TEMP_SOMETHING:.

I already did. And to be really sure also included a space after it.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


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 is not _always_ at the
> beginning of the string, then your code is going to skip
> right over valid match like a round stone skipping across
> the surface of a glass-smooth lake. But if you are sure the
> target will always be at the beginning of the string, then
> it is the best choice.

Yes, I am sure it is always at the beginning of the line. (It is
output from the Linux sensors command.)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 implement this?


>>> No need for a regex just yet:
>>>
>>> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>>>
>>> (btw, note that the result of this expression is a list, not an array, for
>>> future Googling.)
>>>
>>> --Ned.
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>> 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
>> useful to see some sample data of the old data, and the new data
>
> There is now also a line that starts with:
> PCH_CPU_TEMP:
>
> And I do not want that one.

You'll probably want to include the ':' in the startswith check,
in case someday they also add CPU_TEMP_SOMETHING:.

-- 
Neil Cerutti

-- 
https://mail.python.org/mailman/listinfo/python-list


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 message.  His messages are 
famous for their outrageous and/or abrasive tone, something he seems to 
revel in.  Luckily, it's not typical of the Python community.


Or take Rick's 'rest' as a suggestion to reread Library Reference 
chapters 2, 3, 4 and in particular 4.7.


As for your idea of an RE, '^' matches the beginning of a line, and '$' 
the end, though using .startswith, and .endswith, are easier if no other 
RE syntax is needed for matching.


--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


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 outrageous and/or abrasive tone, something he seems to 
revel in.  Luckily, it's not typical of the Python community.


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


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
> > useful to see some sample data of the old data, and the
> > new data

@Goldstick 

"Inclusion testing" will return false positives when the
target is part of a larger structure (aka: word). Observe:

>>> s = "Complex is better than complicated."
>>> "plex" in s
True
>>> "om" in s
True
>>> s.count("om")
2

I'm sure you already know this, and only made the comment
because you did not have all the data, but i thought it would
be good to mention for any lurkers who may be watching.

> 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 is not _always_ at the
beginning of the string, then your code is going to skip
right over valid match like a round stone skipping across
the surface of a glass-smooth lake. But if you are sure the
target will always be at the beginning of the string, then
it is the best choice.

> -- 
> Cecil Westerhof
> Senior Software Engineer

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

If you really are a "_Senior_ software engineer", and that
title is not simply an ego-booster bestowed by your boss to
a one-person-dev-team in order to avoid pay raises, then i
would expect more competence from someone who holds such an
esteemed title.

And even *IF* you are only vaguely familiar with Python, and
even *IF*, you rarely use Python in your projects, i don't
think it's too much to ask of a ~~Senior~~ Software Engineer
that they possess the basic skills required to peruse the
Python documentation and decide which method is most
appropriate for the situation at hand. And if you're using
Python on a regular basis, then you should be intimately
familiar with _all_ methods of each major type. 

Granted, your question did "hint" about the possibility of
using a regexp (although, based on the data you have
provided so far, a string method will suffice), but i would
also expect a ~~Senior~~ Software Engineer to not only be
knowledgeable of regexps, but also know when they are a
strength and when they are a weakness.

Now, there are one of two ways you can take this advice:

(1) You can take it as a personal attack; get all huffy
about it; drop to the floor and flail your arms and legs
like a petulant two-year-old who didn't get the toy he
wanted; and learn nothing in the process.

or

(2) You can take it as what it is -> constructive criticism;
shower me with gratitude[1]; and become a better person and
a better programmer in the process.

The choice is yours. 


[1] Well, i had to sneak something in there for myself,
after all, it is the season of giving, yes? O:-)

Here comes santa claws...
Here comes santa claws...
...

-- 
https://mail.python.org/mailman/listinfo/python-list


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 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 implement this?
>>>
>>>
>> No need for a regex just yet:
>>
>> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>>
>> (btw, note that the result of this expression is a list, not an array, for
>> future Googling.)
>>
>> --Ned.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
> 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
> useful to see some sample data of the old data, and the new data

There is now also a line that starts with:
PCH_CPU_TEMP:

And I do not want that one.

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


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 the
>> beginning of the line. What would be the best way to implement this?
>>
>
> No need for a regex just yet:
>
>     array = [elem for elem in output if elem.startswith('CPU_TEMP')]

Yes, that is it. I should have known that. :'-(

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
-- 
https://mail.python.org/mailman/listinfo/python-list


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, I have to check for CPU_TEMP at the
>> beginning of the line. What would be the best way to implement this?
>>
>>
> No need for a regex just yet:
>
> array = [elem for elem in output if elem.startswith('CPU_TEMP')]
>
> (btw, note that the result of this expression is a list, not an array, for
> future Googling.)
>
> --Ned.
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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
useful to see some sample data of the old data, and the new data

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


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 implement this?



No need for a regex just yet:

    array = [elem for elem in output if elem.startswith('CPU_TEMP')]

(btw, note that the result of this expression is a list, not an array, 
for future Googling.)


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


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. What would be the best way to implement this?
> 
> -- 
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Use https://docs.python.org/3/library/stdtypes.html#str.startswith instead of 
the test for `in`.

--
Kindest regards.

Mark Lawrence.
-- 
https://mail.python.org/mailman/listinfo/python-list