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
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
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 va
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
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
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". Ho
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:
>
> --8<--
Python 3.10.5 (v3.10.5:f37715, Jul 10 2022, 00:26:17) [GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x,_,z = [1,2,3]
Works as expected.
Now I didn't expect the following to work (but Python sometimes
surprises me!), so I tried:
>>
Karsten Hilbert writes:
Python 3.11.2 (main, Aug 26 2024, 07:20:54) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more
information.
>>> tex = '\sout{'
>>> tex
'\\sout{'
>>>
Am I missing something ?
あうぇくろ writes:
tpr=composite(type,print)
print(tpr('a')==tpr(1))
Why does tpr('a')==tpr(1) return True?
Because tpr always returns the value None.
--
https://mail.python.org/mailman/listinfo/python-list
10 matches
Mail list logo