07.02.12 00:06, Matej Cepl написав(ла):
return seq[int(random.random() * len(seq))]
doesn't seem like something so terrible (and maintenance intense). :)
_choice('abc') returns 'a' with probability P('a') =
1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with
Am 06.02.2012 09:45, schrieb Matej Cepl:
Also, how could I write a re-implementation of random.choice which would
work same on python 2.6 and python 3.2? It is not only matter of unit
tests, but I would really welcome if the results on both versions
produce the same results.
Two approaches
On Mon, 06 Feb 2012 02:27:14 -0500, Terry Reedy wrote:
[...]
and should be treated as a bug. Raymond made a strong case arguing for
repeatability, and then approved a bug fix that broke repeatability. I
doubt that was deliberate.
It was deliberate that randrange was changed to an even
of random.choice which would
work same on python 2.6 and python 3.2? It is not only matter of unit
tests, but I would really welcome if the results on both versions
produce the same results.
Could we get some hint in the release notes?
Thanks for the help,
Matěj
--
http://mail.python.org/mailman
On 6.2.2012 09:45, Matej Cepl wrote:
Also, how could I write a re-implementation of random.choice which would
work same on python 2.6 and python 3.2? It is not only matter of unit
tests, but I would really welcome if the results on both versions
produce the same results.
Silly, of course
Steven D'Aprano wrote:
A more explicit note will help, but the basic problem applies: how do you
write deterministic tests given that the random.methods (apart from
random.random itself) can be changed without warning?
Biting the bullet would mean supplying your own PRNG, under your control.
On 02/06/2012 09:57 AM, Matej Cepl wrote:
On 6.2.2012 09:45, Matej Cepl wrote:
Also, how could I write a re-implementation of random.choice which would
work same on python 2.6 and python 3.2? It is not only matter of unit
tests, but I would really welcome if the results on both versions
produce
On 02/06/12 12:48, Aaron France wrote:
On 02/06/2012 09:57 AM, Matej Cepl wrote:
Silly, of course, the solution is obvious ... I have just
embedded random.choice from 2.6 to my code.
Matěj
Is the above actually a good idea though?
What I understand you're doing is embedding the source from
On 6.2.2012 20:26, Tim Chase wrote:
In an ideal world, the code wouldn't have broken backwards compat.
However, given the conditions, if Matej is willing to forgo bug-fixes,
it's a reasonable solution. The alternate might be to try moving the
recent/fixed version into the old project and
Hi,
I have this working function:
def as_xml(self):
out = etree.Element(or)
for k in sorted(self.keys()):
out.append(etree.Element(hostname,
attrib={'op': '=', 'value': random.choice(self[k])}))
# ... return somehow string representing XML
On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote:
Strange thing is that this unit tests correctly with python3, but fails
with python2. The problem is that apparently python3 random.choice picks
different element of self[k] than the one python2 (at least, both of
them are constant in
On 2/5/2012 11:01 PM, Steven D'Aprano wrote:
Reading the docs, I would expect that when using an int as seed, you
should get identical results.
That is similar to expecting hash to be consistent from version to version.
There is no mention that the PRNG has changed between 2.6 and 3.2;
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote:
On 2/5/2012 11:01 PM, Steven D'Aprano wrote:
Reading the docs, I would expect that when using an int as seed, you
should get identical results.
That is similar to expecting hash to be consistent from version to
version.
No. hash is
On 2/6/2012 12:56 AM, Steven D'Aprano wrote:
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote:
On 2/5/2012 11:01 PM, Steven D'Aprano wrote:
Reading the docs, I would expect that when using an int as seed, you
should get identical results.
That is similar to expecting hash to be
I'm using 2.7.1, because that's what my Ubuntu 11.04 bundles (python --
version reports 2.7.1+ though, no idea what the + means). On the other
hand, Ubuntu provides 3.2 packages via apt-get, so I'm in the process
of migrating to 3k. I really like the focus on laziness in 3k (don't
know if 'focus'
On Tue, Jun 14, 2011 at 9:08 AM, SigmundV sigmu...@gmail.com wrote:
To the OP I'd say: learn Python through 3.2. It's the best way
forward, for the sake of yourself and others. The only way more
modules can become 3k compatible is if more people use 3k.
I skipped 3.2 and went straight to 3.3a0
On Thu, Jun 9, 2011 at 11:00 PM, harrismh777 harrismh...@charter.net wrote:
Andrew Berg wrote:
AFAICT, there are three reasons to learn Python 2:
... there is a fourth reason.
The linux distro you are using currently was customized with python 2.x
I ran into this problem this week in
Terry Reedy wrote:
A couple of years ago, users were people who were already programming
with 2.x. That is changing now.
... big time !
:)
--
http://mail.python.org/mailman/listinfo/python-list
Andrew Berg wrote:
AFAICT, there are three reasons to learn Python 2:
... there is a fourth reason.
The linux distro you are using currently was customized with python 2.x
I ran into this problem this week in fact... on my HP g6 ubuntu notebook
running 10.04 lucid. It ships with the
On Thu, Jun 9, 2011 at 11:00 PM, harrismh777 harrismh...@charter.net wrote:
Andrew Berg wrote:
AFAICT, there are three reasons to learn Python 2:
... there is a fourth reason.
The linux distro you are using currently was customized with python 2.x
I ran into this problem this week in
On Fri, 10 Jun 2011 01:00:35 -0500, harrismh777 wrote:
So, be careful. I have had to separate *all* of my python installs on
*every* one of my systems for this similar reason. The bottom line is if
the distro ships with 2.6 (minus the idle) chances are that the
interpreter is there *not* to
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference
--
http://mail.python.org/mailman/listinfo/python-list
In 9037ef5f-53c5-42c6-ac5d-8f942df6c...@x38g2000pri.googlegroups.com hisan
santosh.s...@gmail.com writes:
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 06/09/2011 01:18 PM, hisan wrote:
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference
http://wiki.python.org
On Fri, Jun 10, 2011 at 3:18 AM, hisan santosh.s...@gmail.com wrote:
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
As a side point, you should probably use 2.7 rather than 2.6. With
regard to 2.x versus 3.x, Corey already posted a link to an excellent
article.
Chris
whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference
--
http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list
John Gordon wrote:
In 9037ef5f-53c5-42c6-ac5d-8f942df6c...@x38g2000pri.googlegroups.com hisan
santosh.s...@gmail.com writes:
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books
On 6/9/2011 11:41 PM, Kyle T. Jones wrote:
Library support.
I urge people who use 2.x only for library support to let library
authors that they would have preferred a 3.x compatible library. I have
library authors say Why port when none of my users have asked for a port?
A couple of years
On 2011.06.09 12:18 PM, hisan wrote:
Hi All,
Please let me know which one is GOOD whether Python 2.6 OR 3.2.
Please let me know the difference between them.
Please give some refernce site or books to know the difference
I'm just a beginner, but AFAICT, there are three reasons to learn Python
29 matches
Mail list logo