Correct syntax for pathological re.search()

2024-10-08 Thread Michael F. Stemper via Python-list
I'm trying to discard lines that include the string "\sout{" (which is TeX, for those who are curious. I have tried: if not re.search("\sout{", line): if not re.search("\sout\{", line): if not re.search("\\sout{", line): if not re.search("\\sout\{", line): But the lines with that string k

Re: Correct syntax for pathological re.search()

2024-10-08 Thread Michael F. Stemper via Python-list
On 07/10/2024 08.56, Stefan Ram wrote: "Michael F. Stemper" wrote or quoted: if not re.search("\\sout\{", line): So, if you're not down to slap an "r" before your string literals, you're going to end up doubling down on every backslash. Never heard of that before, but it did the trick

Re: IDLE: clearing the screen

2024-06-10 Thread Michael F. Stemper via Python-list
On 08/06/2024 14.18, Rob Cliffe wrote: OK, here is the advanced version: import os class _cls(object):     def __repr__(self):         os.system('cls')         return '' cls = _cls() Now when you type cls it clears the screen.  The only flaw is that there is a blank line at the very top of th

Re: IDLE: clearing the screen

2024-06-10 Thread Michael F. Stemper via Python-list
On 10/06/2024 09.32, Stefan Ram wrote: "Michael F. Stemper" wrote or quoted: On 08/06/2024 14.18, Rob Cliffe wrote: OK, here is the advanced version: import os class _cls(object):     def __repr__(self):         os.system('cls')         return '' cls = _cls() ... Why have it return any

Re: A technique from a chatbot

2024-04-03 Thread Michael F. Stemper via Python-list
On 03/04/2024 13.45, Gilmeh Serda wrote: On 2 Apr 2024 17:18:16 GMT, Stefan Ram wrote: first_word_beginning_with_e Here's another one: def ret_first_eword(): ... return [w for w in ['delta', 'epsilon', 'zeta', 'eta', 'theta'] if w.startswith('e')][0] ... ret_first_eword() 'epsilon'

Re: Popping key causes dict derived from object to revert to object

2024-03-25 Thread Michael F. Stemper via Python-list
On 25/03/2024 01.56, Loris Bennett wrote: Grant Edwards writes: On 2024-03-22, Loris Bennett via Python-list wrote: Yes, I was mistakenly thinking that the popping the element would leave me with the dict minus the popped key-value pair. It does. Indeed, but I was thinking in the contex

Re: RE: Newline (NuBe Question)

2023-11-26 Thread Michael F. Stemper via Python-list
On 24/11/2023 21.45, avi.e.gr...@gmail.com wrote: Grizz[l]y, I think the point is not about a sorted list or sorting in general It is about reasons why maintaining a data structure such as a list in a program can be useful beyond printing things once. There are many possible examples such as hav

Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list
On 25/10/2023 05.45, o1bigtenor wrote: On Tue, Oct 24, 2023 at 8:35 PM Chris Angelico via Python-list wrote: 3. Catch the failure before you commit and push. Unit tests are great for this. Where might I find such please. You don't "find" unit tests; you write them. A unit test tests a spe

Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list
On 24/10/2023 18.15, o1bigtenor wrote: What is interesting about this is the absolute certainty that it is impossible to program so that that program is provably correct. Not entirely true. If I was to write a program to calculate Fibonacci numbers, or echo back user input, that program could

Re: Question(s)

2023-10-25 Thread Michael F. Stemper via Python-list
On 24/10/2023 17.50, Thomas Passin wrote: The programming team for the Apollo moon mission developed a system which,> if you would write your requirements in a certain way, could generate correct C code for them. Since the last Apollo mission was in 1972, when C was first being developed,

Re: error of opening Python

2023-09-26 Thread Michael F. Stemper via Python-list
On 26/09/2023 07.27, Abdelkhelk ashref salay eabakh wrote: Dear Python team, This is my not first time using Python, I tried to launch Python and it showed "Python 3.11.3 (tags/v3.11.3:f3909b8, Apr 4 2023, 23:49:59) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "l