Mark Bell added the comment:
To give two more consequences of `random.choices` using floating point
arithmetic:
1) When doing `random.choices([A, B, C], weights=[2**55, 1, 1])` the cumulative
weight to bisect for is selected using `floor(random() * (2**55 + 1 + 1 +
0.0))`. Since this is
New submission from Mark Bell :
The docstring for `random.choices` indicates that
```
import random
random.choices(population, k=1)
```
should produce a list containing one item, where each item of `population` has
equal likelihood of being selected. However `random.choices` draws elements for
Mark Bell added the comment:
> Instead, the discussion was focused on removing *all* empty strings from the
> result.
I imagine that the discussion focussed on this since this is precisely what
happens when sep=None. For example, 'a b c '.split() == ['a'
Mark Bell added the comment:
Andrei: That is a very interesting observation, thank you for pointing it out.
I guess your example / argument also currently applies to whitespace separation
too. For example, if we have a whitespace separated string with contents:
col1 col2 col3
a b c
x y z
Mark Bell added the comment:
Thank you very much for confirming these test cases. Using these I believe that
I have now been able to complete a patch that would implement this feature. The
PR is available at https://github.com/python/cpython/pull/26222. As I am a
first-time contributor
Change by Mark Bell :
--
pull_requests: +24839
pull_request: https://github.com/python/cpython/pull/26222
___
Python tracker
<https://bugs.python.org/issue28
Mark Bell added the comment:
So I think I agree with you about the difference between .split() and .split('
'). However wouldn't that mean that
' x y z'.split(maxsplit=1, keepempty=False) == ['x', &
Mark Bell added the comment:
> suggests that empty strings don't count towards maxsplit
Thank you for the confirmation. Although just to clarify I guess you really
mean "empty strings *that are dropped from the output* don't count towards
maxsplit". Just to double
Mark Bell added the comment:
So I have taken a look at the original patch that was provided and I have been
able to update it so that it is compatible with the current release. I have
also flipped the logic in the wrapping functions so that they take a
`keepempty` flag (which is the opposite
New submission from Mark Bell :
The documentation for itertools.product at:
https://docs.python.org/3/library/itertools.html#itertools.product
currently says that:
For example, product(A, B) returns the same as ((x,y) for x in A for y in B)
While this is broadly correct, since product
Mark Bell added the comment:
I ran some timing tests of the patch I submitted to compare it to the current
build of Python. Using timit on the current master branch I got:
python.exe -m timeit "sum(())" 1.12 usec per loop
python.exe -m timeit "sum((), 0)"
Changes by Mark Bell :
--
type: -> behavior
___
Python tracker
<http://bugs.python.org/issue31141>
___
___
Python-bugs-list mailing list
Unsubscrib
New submission from Mark Bell:
The built-in function sum takes an optional argument "start" to specify what
value to start adding from (defaults to 0). This argument should be a keyword
argument in order to match the other built-in functions such as:
enumerate(range(10), star
New submission from John-Mark Bell:
In low-memory scenarios, the Python 2.7 interpreter may crash as a result of
failing to correctly check the return value from mmap in new_arena().
This changeset appears to be the point at which this issue was introduced:
http://hg.python.org/cpython/rev
New submission from Mark Bell:
The following example is a Tkinter app with a button that toggles the menu
being enabled based off of
https://mail.python.org/pipermail/tkinter-discuss/2004-September/000204.html
#---
from Tkinter import *
root=Tk()
def hello
15 matches
Mail list logo