Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 10:49 AM, eryksun wrote: > On Sun, Aug 12, 2012 at 10:58 AM, Dave Angel wrote: > Good catch in Kent Johnson's code. Maybe he'll search for his name and > find this. It should be `r = r // factor`. The fault was probably mine. Kent wrote this in 2004, in Python 2.x. When

Re: [Tutor] pickle problems

2012-08-12 Thread Peter Otten
Richard D. Moores wrote: > f = open("factors.txt", 'rb') > data = pickle.load(f) > f.close f.close looks up the close method but doesn't invoke it; you need f.close(). Alternatively use a with statement: with open("factors.txt", "rb") as f: data = pickle.load(f) This will close the file eve

Re: [Tutor] pickle problems

2012-08-12 Thread eryksun
On Sun, Aug 12, 2012 at 10:58 AM, Dave Angel wrote: > > 2) You wind up with a floating point number. If you're getting floats, > then you're limited to their precision, maybe 18 digits, and limited to > their speed. Perhaps you need to use the // divide rather than the / > one. And perhaps it'd

Re: [Tutor] How to deploy Python 2.7, Django in OpenShift

2012-08-12 Thread Alan Gauld
On 12/08/12 13:26, Surya K wrote: I am really fed up with tutorials on web telling how to configure Django & Python 2.7 on OpenShift DIY. I assume you intended to send this to a Django programming forum? This is the python tutor list for people learning the Python langua

Re: [Tutor] pickle problems

2012-08-12 Thread Dave Angel
On 08/12/2012 04:44 AM, Richard D. Moores wrote: > > > One caveat is that I have yet to fix the problem with lines 75-78. > > One thing I'd like to implement is a monitor of the time > factorsOfInteger(n) takes to process some of the 18-digit ints (line > 153). Most are processed within a second

Re: [Tutor] How to deploy Python 2.7, Django in OpenShift

2012-08-12 Thread Mark Lawrence
On 12/08/2012 13:26, Surya K wrote: I am really fed up with tutorials on web telling how to configure Django & Python 2.7 on OpenShift DIY. So, can write a detailed step-by-step procedure on how to setup Django 1.4 with Python 2.7 on OpenShift using VirtualEnv?? Thanks a lot!!

Re: [Tutor] pickle problems

2012-08-12 Thread eryksun
On Sun, Aug 12, 2012 at 8:46 AM, eryksun wrote: > > t = threading.Thread(target=factorsOfInteger, args=(n, qin, qout)).start() Sorry I need to proofread better. That should be the following: t = threading.Thread(target=factorsOfInteger, args=(n, qin, qout)) t.start()

Re: [Tutor] pickle problems

2012-08-12 Thread eryksun
On Sun, Aug 12, 2012 at 7:44 AM, Richard D. Moores wrote: > > I just discovered > os.path.getsize('factors.txt') > and that factors.txt has a size of 2 bytes when "empty". > (I changed the file extension to .txt so I could delete the contents.) No, an empty file has no data; the size is 0. You mu

Re: [Tutor] pickle problems

2012-08-12 Thread eryksun
On Sun, Aug 12, 2012 at 4:44 AM, Richard D. Moores wrote: > > OK, thanks for the code, which I will duly study. However, I just > pasted my new version, pickle_attempt_for_web2.py at > . I've tested it and tested it, and it > does exactly what I wanted (thanks to you!

[Tutor] How to deploy Python 2.7, Django in OpenShift

2012-08-12 Thread Surya K
I am really fed up with tutorials on web telling how to configure Django & Python 2.7 on OpenShift DIY. So, can write a detailed step-by-step procedure on how to setup Django 1.4 with Python 2.7 on OpenShift using VirtualEnv?? Thanks a lot!!

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 2:13 AM, Richard D. Moores wrote: . > But what > about case where factors.dat is empty? Is there a test for that? I just discovered os.path.getsize('factors.txt') and that factors.txt has a size of 2 bytes when "empty". (I changed the file extension to .txt so I could dele

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sun, Aug 12, 2012 at 1:00 AM, Alan Gauld wrote: > On 12/08/12 03:43, Richard D. Moores wrote: > >> === >> if "factors.dat": > > This is testing if the string is True, which it always is. > I assume you intended something like > > if os.path.exists('factors.dat'): > > >> f = open("f

Re: [Tutor] pickle problems

2012-08-12 Thread Richard D. Moores
On Sat, Aug 11, 2012 at 9:51 PM, eryksun wrote: > On Sat, Aug 11, 2012 at 11:19 PM, Richard D. Moores > wrote: >> >>> To clarify, you can store multiple pickles in a file, but each needs >>> its own load. So you'd have to maintain a session dictionary for the >>> factors of new integers. Then ap

Re: [Tutor] pickle problems

2012-08-12 Thread Alan Gauld
On 12/08/12 03:43, Richard D. Moores wrote: === if "factors.dat": This is testing if the string is True, which it always is. I assume you intended something like if os.path.exists('factors.dat'): f = open("factors.dat", 'rb') data = pickle.load(f) f.close D = dat