Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Blockheads Oi Oi
On 23/01/2012 06:15, Shreesh bhat wrote: Calculating the table is fast. I think either my luckiness test (where i find the sum of all digits and sum of squares of all digits of a large number) or generating numbers is slow. Don't think, know :) Tools like the profile or timeit modules are ther

[Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Shreesh bhat
Thank you all for helping me understand the overflow error. I m a newbie on mailing lists.I apologize for my errors. Program: def sieve(maxi): primes = range(2,maxi+1) for i in primes: j = 2 while i * j <= primes[-1]: if i * j in primes: primes.remove(i*j) j += 1

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Shreesh bhat
Calculating the table is fast. I think either my luckiness test (where i find the sum of all digits and sum of squares of all digits of a large number) or generating numbers is slow. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscri

Re: [Tutor] how to handle very large numbers

2012-01-22 Thread Dave Angel
On 01/22/2012 09:08 PM, Surya K wrote: Well, I have been doing a puzzle where I have to deal with number 10^18. A variable can store that value but can't do operations.Ex: If I use range() on it, it shows overflow error. So, How do I handle this. I have to use range() for that number.. in this

[Tutor] how to handle very large numbers

2012-01-22 Thread Surya K
Well, I have been doing a puzzle where I have to deal with number 10^18. A variable can store that value but can't do operations.Ex: If I use range() on it, it shows overflow error. So, How do I handle this. I have to use range() for that number.. in this instance. Also mention how to handle i

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Dave Angel
You sent me this message privately, instead of on the list (use Reply-All in most mail programs). Two problems with that: 1) nobody else gets to help 2) I don't give private help, except as a contractor. On 01/22/2012 12:44 PM, Shreesh bhat wrote: *Lucky numbers:* def sieve(maxi): prime

Re: [Tutor] Importing functions in IPython

2012-01-22 Thread bob gailer
On 1/22/2012 5:43 PM, Alan Gauld wrote: On 22/01/12 22:10, Jaidev Deshpande wrote: In[1]: from mymodule import myfunc In[3]: from mymodule import myfunc it doesn't work as per the new changes. I have to close IPython and start all over again. You can use reload() to reload the entire module

Re: [Tutor] Importing functions in IPython

2012-01-22 Thread bob gailer
On 1/22/2012 5:10 PM, Jaidev Deshpande wrote: Dear List, Suppose I have a function myfunc() in a module called mymodule.py As usual, I import this function in IPython with In[1]: from mymodule import myfunc Now if I find that there is something wrong with myfunc, I can open mymodule.py with a

Re: [Tutor] Importing functions in IPython

2012-01-22 Thread Alan Gauld
On 22/01/12 22:10, Jaidev Deshpande wrote: In[1]: from mymodule import myfunc In[3]: from mymodule import myfunc it doesn't work as per the new changes. I have to close IPython and start all over again. You can use reload() to reload the entire module, but I confess I don't know how to relo

Re: [Tutor] Importing functions in IPython

2012-01-22 Thread Steven D'Aprano
On Mon, Jan 23, 2012 at 03:40:26AM +0530, Jaidev Deshpande wrote: > Dear List, > > Suppose I have a function myfunc() in a module called mymodule.py [...] > Now when I delete the original function and import the changed one, > > In[2]: del myfunc > In[3]: from mymodule import myfunc > > it doesn

[Tutor] Importing functions in IPython

2012-01-22 Thread Jaidev Deshpande
Dear List, Suppose I have a function myfunc() in a module called mymodule.py As usual, I import this function in IPython with In[1]: from mymodule import myfunc Now if I find that there is something wrong with myfunc, I can open mymodule.py with a suitable editor and make the required changes.

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Alan Gauld
On 22/01/12 11:37, Shreesh bhat wrote: Steven wrote: " Scale your numbers from time to time, to avoid them getting too big " What does this mean? It could be done in various ways but one simple example is, low = 100 hi = 110 for n in range(low,hi): ... code uses n ... c

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Dave Angel
On 01/22/2012 06:37 AM, Shreesh bhat wrote: I m using Python 2.7 Steven wrote: " Scale your numbers from time to time, to avoid them getting too big" What does this mean? inp refers to the sample input test case I have given at first.Its a string containing two numbers, The program has to handle

Re: [Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Peter Otten
Shreesh bhat wrote: > I m using Python 2.7 > Steven wrote: > " Scale your numbers from time to time, to avoid them getting too big " > What does this mean? > > inp refers to the sample input test case I have given at first.Its a > string containing two numbers, > The program has to handle large n

Re: [Tutor] Setting Network settings from Python/Djang

2012-01-22 Thread ian douglas
Well DNS would be easy, just modify /etc/resolve.conf ... the other files you need to modify would depend on your distro because they all do something slightly different it seems. On Jan 22, 2012 3:25 AM, "Ganesh Kumar" wrote: > I'm working on a simple web interface for an embedded computer. The

[Tutor] OverflowError in lucky numbers script

2012-01-22 Thread Shreesh bhat
I m using Python 2.7 Steven wrote: " Scale your numbers from time to time, to avoid them getting too big " What does this mean? inp refers to the sample input test case I have given at first.Its a string containing two numbers, The program has to handle large numbers till 10**18 and also has to ex

Re: [Tutor] Tutor Digest, Vol 95, Issue 55

2012-01-22 Thread Steven D'Aprano
Shreesh bhat wrote: *Lucky Numbers* A number is called lucky if the sum of its digits, as well as the sum of the squares of its digits is a prime number. How many numbers between A and B are lucky? Very little of this is relevant to your problem. In the future, please provide a short, self-con

Re: [Tutor] Tutor Digest, Vol 95, Issue 55

2012-01-22 Thread Alan Gauld
On 22/01/12 06:11, Shreesh bhat wrote: Here goes some general comments that will make it esier to understand your code and therefore, hopefully, the problem. def isprime(n): def islucky(n): . There are more efficient ways of doing both tests but I'll igniore that for

[Tutor] Setting Network settings from Python/Djang

2012-01-22 Thread Ganesh Kumar
I'm working on a simple web interface for an embedded computer. The computer will ship with a static default ip that will then need to be updated by the install tech who may not be tech/linux savvy. Basicly I need to change the following system settings from a Django app. 1. IP Addres 2. Su

[Tutor] OverflowError in lucky numbers script, was Re: Tutor Digest, Vol 95, Issue 55

2012-01-22 Thread Peter Otten
Shreesh bhat wrote: > *Lucky Numbers* > A number is called lucky if the sum of its digits, as well as the sum of > the squares of its digits is a prime number. How many numbers between A > and B are lucky? > Input: > The first line contains the number of test cases T. Each of the next T > lines co