Re: [Tutor] How to test function using random.randint()?

2016-03-19 Thread boB Stepp
On Sat, Mar 19, 2016 at 8:03 AM, Steven D'Aprano wrote: > On Sat, Mar 19, 2016 at 04:05:58PM +1100, Ben Finney wrote: > >> import random >> >> def roll_die(num_sides, rng=None): >> """ Return a result from a random die of `num_sides` sides. >> >> :param num_sides: The n

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Peter Otten
Alan Gauld wrote: > On 18/03/16 15:31, Peter Otten wrote: > >> I suppose he thinks that hexadecimal and binary is the same. The data you >> showed is binary. For example the following sequence of bytes >> >> 9 1 120 1 253 2 >> >> is displayed as the bytestring >> >> b'\t\x01x\x01\xfd' > > Wha

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Peter Otten
Yeh wrote: > Thanks for your help, > > Sorry for top-post and MUC. It is MCU - Micro Controller Unit. > >> I supposed that you are trying to read binary data. > > my friend said to me that the data should be the hexadecimal, and I need > convert them to string "YY" and decimal integers first. b

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-19 Thread Steven D'Aprano
On Wed, Mar 16, 2016 at 08:36:59AM +, Matt Williams wrote: > Dear Tutors, > > I am looking for some advice. I have some data that has three dimensions to > it. I would like to store it such that one could manipulate (query/ update/ > etc.) by dimension - so it would be feasible to ask for all

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Alan Gauld
On 18/03/16 15:31, Peter Otten wrote: > I suppose he thinks that hexadecimal and binary is the same. The data you > showed is binary. For example the following sequence of bytes > > 9 1 120 1 253 2 > > is displayed as the bytestring > > b'\t\x01x\x01\xfd' What happened to the 2 at the end? Sh

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Peter Otten
Yeh Z wrote: [Please don't top-post. Thank you] >Thanks for your help, > >It's my bad, I should put them to a list, not a array? >such as: >YY, 100, 140, 200, 110, 160? I supposed that you are trying to read binary data. >Firstly, I'm confused about how to convert them to

[Tutor] Two web apps (was Re: Advice on multi-dimensional data storage)

2016-03-19 Thread Alan Gauld
On 17/03/16 17:48, sina sareth via Tutor wrote: Please start a new thread for a new subject and please change the subject line it makes searching the archives much easier. > Hi thereI would like to make 2 apps I wonder if somebody has a similar codes. > We would need a bit more background inf

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Yeh Z
Thanks for your help, It's my bad, I should put them to a list, not a array? such as: YY, 100, 140, 200, 110, 160? Firstly, I'm confused about how to convert them to string and integers? the raw bytes? Is it different to the bytes packing by "pack"? I want to read them by a h

Re: [Tutor] (SIP installation problem) Best way to install Python 3 onto Windows 10

2016-03-19 Thread Alan Gauld
On 17/03/16 11:32, CMG Thrissur wrote: >>> But Winpython portable version works like a charm on windows. >> > I think linux is much better and i will stick to it, but at work i have > to work on win 10 and that to i sometimes have to make python utilities > for others to work on which requires a

Re: [Tutor] How to test function using random.randint()?

2016-03-19 Thread Alan Gauld
On 19/03/16 13:03, Steven D'Aprano wrote: > But all joking aside, Python's pseudo-random number generator is one of > the best in the world, the Mersenne Twister. For non-cryptographical > purposes, it is as random as anything you are likely to need. > > https://en.wikipedia.org/wiki/Mersenne_T

Re: [Tutor] How to test function using random.randint()?

2016-03-19 Thread Steven D'Aprano
On Sat, Mar 19, 2016 at 04:05:58PM +1100, Ben Finney wrote: > import random > > def roll_die(num_sides, rng=None): > """ Return a result from a random die of `num_sides` sides. > > :param num_sides: The number of sides on the die. > :param rng: An instance

Re: [Tutor] How to test function using random.randint()?

2016-03-19 Thread Steven D'Aprano
On Fri, Mar 18, 2016 at 11:26:13PM -0500, boB Stepp wrote: > If I had a function to roll a die, such as: > > import random > > def roll_die(num_sides): > return random.randint(1, num_sides) > > How would I write unit tests for this? (1) One way would be to monkey-patch the random module wi

Re: [Tutor] how to transform the data as below?

2016-03-19 Thread Yeh
Thanks for your help, Sorry for top-post and MUC. It is MCU - Micro Controller Unit. > I supposed that you are trying to read binary data. my friend said to me that the data should be the hexadecimal, and I need convert them to string "YY" and decimal integers first. but why the data which I

Re: [Tutor] How to test function using random.randint()?

2016-03-19 Thread Alan Gauld
On 19/03/16 04:26, boB Stepp wrote: > If I had a function to roll a die, such as: > > How would I write unit tests for this? Ben has given the general case answer. > And I do not see how I can test for an appropriate "randomness" to the > numbers the function generates without to a lot of iter

Re: [Tutor] (SIP installation problem) Best way to install Python 3 onto Windows 10

2016-03-19 Thread CMG Thrissur
On Thursday 17 March 2016 12:40 AM, eryk sun wrote: On Wed, Mar 16, 2016 at 12:56 PM, Alan Gauld wrote: On 16/03/16 12:46, CMG Thrissur wrote: I tried to install activestate on win 10 but due to my ignorance or lack of knowlege i could n't get to install pyqt or sip. i tried it through pip

Re: [Tutor] Best way to install Python 3 onto Windows 10

2016-03-19 Thread paul . hermeneutic
I would visit http://www.python.org/ and hover over the "Downloads" text, then choose the desired package. If you want a 64-bit kit, go to https://www.python.org/downloads/release/python-351/ and choose "Windows x86-64 executable installer". On Tue, Mar 15, 2016 at 3:31 PM, Ken G. wrote: > Havin

Re: [Tutor] (SIP installation problem) Best way to install Python 3 onto Windows 10

2016-03-19 Thread Alan Gauld
On 16/03/16 12:46, CMG Thrissur wrote: > > Personally I always install ActiveState Python on > > Windows > I tried to install activestate on win 10 but due to my ignorance or > lack of knowlege i could n't get to install pyqt or sip. i tried it > through pip. Active state only installs standar

Re: [Tutor] Advice on multi-dimensional data storage

2016-03-19 Thread Bob Gailer
On Mar 16, 2016 5:59 AM, "Matt Williams" wrote: > > Dear Tutors, > > I am looking for some advice. I have some data that has three dimensions to > it. I would like to store it such that one could manipulate (query/ update/ > etc.) by dimension - so it would be feasible to ask for all of the data >

Re: [Tutor] (SIP installation problem) Best way to install Python 3 onto Windows 10

2016-03-19 Thread CMG Thrissur
On Wednesday 16 March 2016 11:26 PM, Alan Gauld wrote: On 16/03/16 12:46, CMG Thrissur wrote: Personally I always install ActiveState Python on Windows I tried to install activestate on win 10 but due to my ignorance or lack of knowlege i could n't get to install pyqt or sip. i tried it thro