Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Serhiy Storchaka
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Ulrich Eckhardt
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Steven D'Aprano
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Mel Wilson
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.

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Aaron France
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Tim Chase
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
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

difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Matej Cepl
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
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;

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
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

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
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

Re: Python 2.6 OR 3.2

2011-06-13 Thread SigmundV
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'

Re: Python 2.6 OR 3.2

2011-06-13 Thread Chris Angelico
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

Re: Python 2.6 OR 3.2

2011-06-13 Thread geremy condra
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

Re: Python 2.6 OR 3.2

2011-06-10 Thread harrismh777
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

Re: Python 2.6 OR 3.2

2011-06-10 Thread harrismh777
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

Re: Python 2.6 OR 3.2

2011-06-10 Thread Benjamin Kaplan
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

Re: Python 2.6 OR 3.2

2011-06-10 Thread Steven D'Aprano
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

Python 2.6 OR 3.2

2011-06-09 Thread hisan
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread John Gordon
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Corey Richardson
-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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Chris Angelico
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Dan Stromberg
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Kyle T. Jones
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Terry Reedy
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

Re: Python 2.6 OR 3.2

2011-06-09 Thread Andrew Berg
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