Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Michael Hall
I am still not understanding what it is I am being asked to do. What is the differance between my_list = [] an my_list[ ] because when I use my_list[] I get an error. Not sure what I am doing wrong. I am asking if you are given the following question how would you write the program. I have most of

Re: [Tutor] executing dynamic code with exec?

2011-12-01 Thread Steven D'Aprano
Chris Hare wrote: What I am trying to do is create a set of variables based upon the table names in the table variables. I have similar code which dynamically creates check buttons and the associated grid. But I suspect those won't work either. What have I got wrong? Everything! Seriously

[Tutor] executing dynamic code with exec?

2011-12-01 Thread Chris Hare
I have this code chunk: tables = ["Farm", "Animals", "AnimalTypes","Users","Roles","Capabilities","Pedigrees","ChipMaker","Owner","Providers","RegistryL"] for x in tables: cmd = "self.cb" + x + "Read = IntVar()" exec cmd in locals(), globals() When the code is executed, I get th

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Steven D'Aprano
Robert Sjoblom wrote: So you can roughly double the speed of your function by skipping even numbers other than two. Remember that 2 itself is prime, but any other multiple of 2 is not. Take that test outside of the loop, and then loop over every second number starting with 3. So, if I understo

Re: [Tutor] is there a better way to organise this code

2011-12-01 Thread bob gailer
On 11/30/2011 8:46 PM, Dave Angel wrote: On 11/30/2011 07:49 PM, Steven D'Aprano wrote: Norman Khine wrote: hello, is there a better way to organise this code or optimise it. http://pastie.org/2944797 I stopped looking at his pastie once the background turned black. I'd have had to copy i

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
> So you can roughly double the speed of your function by skipping even > numbers other than two. Remember that 2 itself is prime, but any other > multiple of 2 is not. Take that test outside of the loop, and then loop over > every second number starting with 3. > So, if I understood this right, m

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Steven D'Aprano
Robert Sjoblom wrote: from math import sqrt def isprime(n, factor): if n == 1: return False for x in range(2, round(sqrt(n))): if n % x == 0: return False else: return True factor is not used in the isprime function; get rid of it. A bug in you

Re: [Tutor] Generating dynamic output

2011-12-01 Thread Alan Gauld
On 01/12/11 23:30, Charles Karl Becker wrote: sending this as plain text after the sig, if any indenting is lost please let me know and I can send the file Looks ok to me... a few comments below, the main block was hurting my hewad so I gave up for now. Its late... def build_line(part):

[Tutor] Generating dynamic output

2011-12-01 Thread Charles Karl Becker
Hi everyone, My CS mentor (not school credit, just a friend helping me with some blindspots and pointers, etc) has been having me write, and then extend, a Tic Tac Toe game. Currently I'm working on dynamically creating the board/output with varying sizes so the user can define the size of the bo

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Alan Gauld
On 01/12/11 21:17, Michael Hall wrote: Can anyone else help with this question? Sure lots of us could help. But Dave's doing a good job leading you in the right direction. Is there something that you don't understand? If you ask about specific points we can give specific answers. Meantime I'l

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
> from math import sqrt > > def isprime(n, factor): >    if n == 1: >        return False >    for x in range(2, round(sqrt(n))): Ooops, this should obviously read for x in range(factor, round(sqrt(n))): best regards, Robert S. ___ Tutor maillist - Tut

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
> Well, there are really only a couple of optimizations that you could make. > That's the nice (bad?) thing about primes - you really only *can* brute > force a solution. That's why nice things like encryption exist. Yes, I know that; perhaps I was unclear but my issues with brute force are for sol

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Steven D'Aprano
Wayne Werner wrote: [...] Well, there are really only a couple of optimizations that you could make. That's the nice (bad?) thing about primes - you really only *can* brute force a solution. That's why nice things like encryption exist. Brute force is a little strong, but not far from the mark.

Re: [Tutor] New plot over the old graph

2011-12-01 Thread stm atoc
I appreciated for the accurate response. I used step by step and it is running now. Thank you very much for your advice and guidance, Sue On Thu, Dec 1, 2011 at 10:01 PM, Andreas Perstinger wrote: > On 2011-12-01 19:20, stm atoc wrote: >> >> Thanks for all information/websites and advice. Yes

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Michael Hall
Can anyone else help with this question? On Thu, Dec 1, 2011 at 12:17 PM, Dave Angel wrote: > (You top-posted, so I'm deleting all the out-of-order stuff. in these > forums, you should put your response after whatever you quote.) > > > On 12/01/2011 02:55 PM, Michael Hall wrote: > >> The OP has

Re: [Tutor] New plot over the old graph

2011-12-01 Thread Andreas Perstinger
On 2011-12-01 19:20, stm atoc wrote: Thanks for all information/websites and advice. Yes the graph is exactly like the one you mentioned. Also, I would like to have them in one not two, but I think since the dimension of the x and y are not same, I have no choice. What I like to do now is comp

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
(You top-posted, so I'm deleting all the out-of-order stuff. in these forums, you should put your response after whatever you quote.) On 12/01/2011 02:55 PM, Michael Hall wrote: The OP has been taught but is still having an issue and all I am doing is asking for help. Here is what I have so fa

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Michael Hall
The OP has been taught but is still having an issue and all I am doing is asking for help. Here is what I have so far # 1) a perfect number is a positive integer that is equal to the # sum of its proper positive divisors,excluding the number itself. # for example, 6 is a perfect number because it

Re: [Tutor] is there a better way to organise this code

2011-12-01 Thread Norman Khine
hi On Thu, Dec 1, 2011 at 12:49 AM, Steven D'Aprano wrote: > Norman Khine wrote: >> >> hello, >> >> is there a better way to organise this code or optimise it. >> http://pastie.org/2944797 > > > Is that a question? Because I get a syntax error in my brain when I parse it > without the question ma

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
(You forgot to post your response on the list, instead posting it privately to me. Please use Reply-All, or whatever the equivalent is on your email app) On 12/01/2011 11:49 AM, Michael Hall wrote: On Thu, Dec 1, 2011 at 7:51 AM, Dave Angel wrote: On 12/01/2011 10:33 AM, Michael Hall wro

Re: [Tutor] New plot over the old graph

2011-12-01 Thread stm atoc
Thanks for all information/websites and advice. Yes the graph is exactly like the one you mentioned. Also, I would like to have them in one not two, but I think since the dimension of the x and y are not same, I have no choice. What I like to do now is comparing 2 (later 3 or more) different sets

Re: [Tutor] New plot over the old graph

2011-12-01 Thread Andreas Perstinger
On 2011-12-01 14:30, stm atoc wrote: With your help, I have a good script from the previous discussion: ** from pylab import * Have you used MATLAB before and are used to its syntax? In general "star imports" (from xxx import *) are a bad practice and IMHO should be avoided. import

Re: [Tutor] Need help adding a funcation

2011-12-01 Thread Dave Angel
On 12/01/2011 10:33 AM, Michael Hall wrote: Here is the code I have written. # Create main function. def main(): a = input('Please Enter a Number: ') # Ask user for input. number = int(a) x = 1 sum_of = 0 while number> x: if number % x == 0: sum_of

[Tutor] Need help adding a funcation

2011-12-01 Thread Michael Hall
Here is the code I have written. # Create main function. def main(): a = input('Please Enter a Number: ') # Ask user for input. number = int(a) x = 1 sum_of = 0 while number > x: if number % x == 0: sum_of = sum_of + x x += 1 if sum_of == number:

Re: [Tutor] is there a better way to organise this code

2011-12-01 Thread Joel Goldstick
On Wed, Nov 30, 2011 at 8:46 PM, Dave Angel wrote: > On 11/30/2011 07:49 PM, Steven D'Aprano wrote: > >> Norman Khine wrote: >> >>> hello, >>> >>> is there a better way to organise this code or optimise it. >>> http://pastie.org/2944797 >>> >> >> Is that a question? Because I get a syntax error i

Re: [Tutor] Prime Factorization Tool

2011-12-01 Thread Wayne Werner
On Thu, Dec 1, 2011 at 7:15 AM, Robert Sjoblom wrote: > So I've recently started poking at the Project Euler site, because I > feel that I need to practice writing code. For those of you interested > in solving the problems on your own I advice you to not read this, as > it will spoil the solution

[Tutor] twisted web client authentication?

2011-12-01 Thread Paul de Vries
Hi Made something that connects to a httpserver and parses the xml stream it sends. The webserver it has to connect to uses digest authentication. The problem is I don't have a clue how to use digest auth with twisted.web.client. Couln't find any code examples for this. Can somebody help me with

[Tutor] New plot over the old graph

2011-12-01 Thread stm atoc
Hi there, I would like to make a new plot with new data over the old one (with old/first data) in the same condition (shape, dimensions) for comparison and analysis data. With your help, I have a good script from the previous discussion: ** from pylab import * import numpy import ma

[Tutor] Prime Factorization Tool

2011-12-01 Thread Robert Sjoblom
So I've recently started poking at the Project Euler site, because I feel that I need to practice writing code. For those of you interested in solving the problems on your own I advice you to not read this, as it will spoil the solution. Problem 3 is this: The prime factors of 13195 are 5, 7, 13 a

Re: [Tutor] plotting in python

2011-12-01 Thread stm atoc
For previous script that I have written, I had trouble having one plot for all data at the same time and I could see two line for Conc[0] and Conc[1] separately. Now, even I modified Conc = a[1:, N+1:] to Conc = a[0:, N+1:], still one plot is created...which is pretty good and no error! Thank you

Re: [Tutor] plotting in python

2011-12-01 Thread Andreas Perstinger
[Still top-posting :-( ] On 2011-12-01 11:13, stm atoc wrote: Well, I did also change the line in the python script to this: plot(Conc[0],z,'r-',label='initial') plot(Conc[1],z,'b-',label='after 20s') to see both Conc[0] and [1]. And did it work? I will send the output data attaches to thi

Re: [Tutor] plotting in python

2011-12-01 Thread Andreas Perstinger
[Please don't top-post. Put your answers below the text you cite.] On 2011-12-01 09:01, stm atoc wrote: The output of the print len(Conc[0]), len(z) is 100 3600. Now I changed Conc[0] to Conc[1], and the output is: 100 100 So, you've changed the line print len(Conc[0]), len(z) to print len(

[Tutor] Black pastie, was Re: is there a better way to organise this code

2011-12-01 Thread Peter Otten
Dave Angel wrote: > I stopped looking at his pastie once the background turned black. I'd > have had to copy it elsewhere to even read it. There is a combobox in the top right corner of the black area where you can select a sane theme, e. g. "IDLE".

Re: [Tutor] plotting in python

2011-12-01 Thread stm atoc
The output of the print len(Conc[0]), len(z) is 100 3600. Now I changed Conc[0] to Conc[1], and the output is: 100 100 But still I need to see from Concentration from 0. On Thu, Dec 1, 2011 at 5:26 AM, Asokan Pichai wrote: > On Thu, Dec 1, 2011 at 2:38 AM, stm atoc wrote: >> Hi there, >> >> I h