Re: f-string syntax deficiency?

2023-06-06 Thread Mark Bourne via Python-list
Roel Schroeven wrote: Op 6/06/2023 om 16:08 schreef Chris Angelico: On Wed, 7 Jun 2023 at 00:06, Neal Becker wrote: > > The following f-string does not parse and gives syntax error on 3.11.3: > > f'thruput/{"user" if opt.return else "cell"} vs. elevation\n' > > However this expression, which is

Attaching a mock function to another mock breaks reset_mock()

2023-06-19 Thread Mark Bourne via Python-list
I've came across an issue with attaching a mock function to another mock object. It looks like this might be a bug in unittest.mock, but it's possible I'm misunderstanding or doing something wrong. I'm currently using Python 3.8.10, which is the default installed on Ubuntu 20.04. I don't hav

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

2024-03-22 Thread Mark Bourne via Python-list
Loris Bennett wrote: Hi, I am using SQLAlchemy to extract some rows from a table of 'events'. From the call to the DB I get a list of objects of the type sqlalchemy.orm.state.InstanceState I would like to print these rows to the terminal using the 'tabulate' package, the documentation for

Re: Using a background thread with asyncio/futures with flask

2024-03-22 Thread Mark Bourne via Python-list
Thomas Nyberg wrote: Hi, Yeah so flask does support async (when installed with `pip3 install flask[async]), but you are making a good point that flask in this case is a distraction. Here's an example using just the standard library that exhibits the same issue: `app.py` ``` import asyncio i

Re: A missing iterator on itertools module?

2024-04-01 Thread Mark Bourne via Python-list
Stefan Ram wrote: ast wrote or quoted: Why did you renamed itertools as _itertools ? Assume I have a module A.py: import math def f(): pass . Assume I have an additional module B.py: import A . Now, when I'm editing "B.py" in IDLE and type "A.", IIRC IDLE will offer me two pos

Re: A technique from a chatbot

2024-04-04 Thread Mark Bourne via Python-list
Thomas Passin wrote: On 4/2/2024 1:47 PM, Piergiorgio Sartor via Python-list wrote: On 02/04/2024 19.18, Stefan Ram wrote:    Some people can't believe it when I say that chatbots improve    my programming productivity. So, here's a technique I learned    from a chatbot!    It is a structured "

Re: A technique from a chatbot

2024-04-05 Thread Mark Bourne via Python-list
for it to be kept hanging around in memory. Perhaps worse, imagine doing the search in parallel and as sone as it is found anywhere, ... -----Original Message- From: Python-list On Behalf Of Mark Bourne via Python-list Sent: Thursday, April 4, 2024 3:04 PM To: python-list@python.org Subj

Re: A technique from a chatbot

2024-04-05 Thread Mark Bourne via Python-list
Stefan Ram wrote: Mark Bourne wrote or quoted: I don't think there's a tuple being created. If you mean: ( word for word in list_ if word[ 0 ]== 'e' ) ...that's not creating a tuple. It's a generator expression, which generates the next value each time it's called for. If you only ever

Re: Chardet oddity

2024-10-24 Thread Mark Bourne via Python-list
Albert-Jan Roskam wrote: Today I used chardet.detect in the repl and it returned windows-1252 (incorrect, because it later resulted in a UnicodeDecodeError). When I ran chardet as a script (which uses UniversalLineDetector) this returned MacRoman. Isn't charset.detect the correct

Re: Trouble with mocking

2024-09-20 Thread Mark Bourne via Python-list
Norman Robins wrote: I'm somewhat new to mocking for unit tests. I have some code like this: In foo/bar/baz.py I have 2 function I want to mock, one calls the other" def function1_to_mock(): . . . def function2_to_mock(): function1_to_mock() In foo/bar/main.py I import 1 of th

Re: Division-Bug in decimal and mpmath

2024-12-15 Thread Mark Bourne via Python-list
2qdxy4rzwzuui...@potatochowder.com wrote: On 2024-12-14 at 12:08:29 +, Mark Bourne via Python-list wrote: Martin Ruppert wrote: Hi, the division 0.4/7 provides a wrong result. It should give a periodic decimal fraction with at most six digits, but it doesn't. Below is the comparis

Re: Division-Bug in decimal and mpmath

2024-12-14 Thread Mark Bourne via Python-list
Martin Ruppert wrote: Hi, the division 0.4/7 provides a wrong result. It should give a periodic decimal fraction with at most six digits, but it doesn't. Below is the comparison of the result of decimal, mpmath, dc and calc. 0.0571428571428571460292086417861615440675190516880580357142857 decim