Re: how to discover what values produced an exception?

2024-05-06 Thread Alan Bawden via Python-list
Thomas Passin writes: On 5/3/2024 9:56 AM, Johanne Fairchild via Python-list wrote: > How to discover what values produced an exception? Or perhaps---why > doesn't the Python traceback show the values involved in the TypeError? > For instance: > >

Re: Python Dialogs (Posting On Python-List Prohibited)

2024-05-03 Thread Alan Bawden via Python-list
Lawrence D'Oliveiro writes: > Assume you have an expression "s.replace('a','b').replace('c','d'). > replace('e','f').replace('g','h')". Its value is a string which > is the value of s, but with "a" replaced by "b", "c" replaced by > "d", "e" replaced by "f" and "g" replaced by "h".

Re: Is there a way to implement the ** operator on a custom object

2024-02-09 Thread Alan Bawden via Python-list
Chris Angelico writes: > On 08Feb2024 12:21, tony.fl...@btinternet.com wrote: > >I know that mappings by default support the ** operator, to unpack the > >mapping into key word arguments. > > > >Has it been considered implementing a dunder method for the ** > >operator so you

Re: on writing a number as 2^s * q, where q is odd

2023-12-05 Thread Alan Bawden via Python-list
jak writes: Oscar Benjamin ha scritto: ... If we now use the function being discussed: powers_of_2_in(n) (63, 1) we can see that the bit_count() method had to do 63 iterations to count the bits I certainly hope that the bit_count method doesn't count bits by iterating

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
jak writes: Alan Bawden ha scritto: > Julieta Shem writes: > > How would you write this procedure? > def powers_of_2_in(n): > ... > > def powers_of_2_in(n): > return (n ^ (n - 1)).bit_count() - 1 > Great solution, unfortunately the return

Re: on writing a number as 2^s * q, where q is odd

2023-11-29 Thread Alan Bawden via Python-list
Julieta Shem writes: How would you write this procedure? def powers_of_2_in(n): ... def powers_of_2_in(n): return (n ^ (n - 1)).bit_count() - 1 -- https://mail.python.org/mailman/listinfo/python-list

Re: Checking if email is valid

2023-11-02 Thread Alan Bawden via Python-list
Chris Angelico writes: On Thu, 2 Nov 2023 at 15:20, AVI GROSS via Python-list wrote: > Yes, it would be nice if there was a syntax for sending a test > message sort of like an ACK that is not delivered to the recipient > but merely results in some status being sent back such as