New submission from David Albert Torpey <dt...@users.sourceforge.net>:
$ python3.5
Python 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 08:49:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "lice
New submission from David Albert Torpey dt...@users.sourceforge.net:
I would like to left and right shift floats as a fast way to multiply or divide
by a power of 2 without rounding error. The only way to do that now is
t=frexp(x) and y=ldexp(t[0],t[1]+2). But would be better to type y=x2
New submission from David Albert Torpey dt...@users.sourceforge.net:
Floats have fromhex() and hex() to round-trip from and to hexadecimal, but
bytes only have fromhex(), so it's hard to reliably round-trip.
--
messages: 132892
nosy: dtorp
priority: normal
severity: normal
status: open
New submission from David Albert Torpey dt...@users.sourceforge.net:
Dictionary keys are commonly numbers, strings, or tuples. Python has optimized
numbers and strings to remember their hash values on successive calls. Tuples
should do this too since their recursive hash function can take
New submission from David Albert Torpey dt...@users.sourceforge.net:
The purpose of the start argument in str.find() and str.rfind() is to allow for
repeated searches.
def find_third_occurrence(s, value):
... p = s.find(value)
... p = s.find(value, p+1)
... return s.find(value
David Albert Torpey dt...@users.sourceforge.net added the comment:
sorted(tree, cmp=lambda x, y: 1 if x in tree[y] else -1 if y in tree[x] else
0)
and it gets ['A', 'C', 'B', 'E', 'D'].
That cmp function is nonsense and isn't even close to being correct:
from random import shuffle
for i
David Albert Torpey added the comment:
Mr. Dickinson thank you for doing this. I do not know how to help with
a patch. If it helps, here is the code I use in python:
def factorial(n, _known=[1]):
assert isinstance(n, int), Need an integer. This isn't a gamma
assert n = 0, Sorry
New submission from David Albert Torpey:
Add a factorial method. Everybody understands what it means before
they are out of high school and it comes up all the time in statistics
and combinatorics. Ruby has a factorial method and heck even basic
calculators have a factorial key.
print