Re: [Tutor] 2.7.3 generator objects

2012-09-01 Thread Ray Jones
On 09/01/2012 11:39 PM, Alan Gauld wrote: > On 02/09/12 06:44, Ray Jones wrote: >> I was playing with os.walk today. I can use os.walk in a for loop (does >> that make it an iterator or just an irritable? ^_^), but if I assign >> os.walk to 'test' (test = os.walk()), that variable becomes a >> gen

Re: [Tutor] using multiprocessing efficiently to process large data file

2012-09-01 Thread Alan Gauld
On 02/09/12 06:48, eryksun wrote: from multiprocessing import Pool, cpu_count from itertools import izip_longest, imap FILE_IN = '...' FILE_OUT = '...' NLINES = 100 # estimate this for a good chunk_size BATCH_SIZE = 8 def func(batch): """ test

Re: [Tutor] 2.7.3 generator objects

2012-09-01 Thread Alan Gauld
On 02/09/12 06:44, Ray Jones wrote: I was playing with os.walk today. I can use os.walk in a for loop (does that make it an iterator or just an irritable? ^_^), but if I assign os.walk to 'test' (test = os.walk()), that variable becomes a generator object that does not work in a for loop. It d

Re: [Tutor] Running a script in the background

2012-09-01 Thread Alan Gauld
On 02/09/12 04:29, Michael Lewis wrote: I have a script that will run forever. Since it runs forever, I don't want to see the interpreter or command line. I want the program to run in the background so I don't see it at all. That's an OS thing not a Python thing. On Unix it means adding an en

Re: [Tutor] using multiprocessing efficiently to process large data file

2012-09-01 Thread eryksun
On Sat, Sep 1, 2012 at 9:14 AM, Wayne Werner wrote: > > with open('inputfile') as f: > for line1, line2, line3, line4 in zip(f,f,f,f): > # do your processing here Use itertools.izip_longest (zip_longest in 3.x) for this. Items in the final batch are set to fillvalue (defaults to None)

[Tutor] 2.7.3 generator objects

2012-09-01 Thread Ray Jones
I was playing with os.walk today. I can use os.walk in a for loop (does that make it an iterator or just an irritable? ^_^), but if I assign os.walk to 'test' (test = os.walk()), that variable becomes a generator object that does not work in a for loop. From what I can tell, it's supposed to work i

Re: [Tutor] Running a script in the background

2012-09-01 Thread Dwight Hutto
Here's a little more reading for you, found under google search term 'no terminal python script' http://stackoverflow.com/questions/2338951/how-can-i-run-a-py2exe-program-in-windows-without-the-terminal http://ginstrom.com/scribbles/2007/09/12/running-a-python-script-on-windows-without-the-consol

Re: [Tutor] Running a script in the background

2012-09-01 Thread Dwight Hutto
On Sat, Sep 1, 2012 at 11:29 PM, Michael Lewis wrote: > Hi everyone, > > I am sorry to ask this when there are a lot of resources online regarding > the subject, but I've spent the past two days trying to figure this out and > I don't get it. > > I have a script that will run forever > Forever i

Re: [Tutor] Running a script in the background

2012-09-01 Thread c smith
You are thinking of && & is what you want ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Running a script in the background

2012-09-01 Thread Michael Lewis
> For windows not sure but for osx just add an & after the command. > > python myscript.py & > Thanks, but I know about that. I should have been more clear. What I want to do is have the script run in the background without even seeing the terminal. Adding the & after the command will let do other

Re: [Tutor] Running a script in the background

2012-09-01 Thread Michael Crawford
For windows not sure but for osx just add an & after the command. python myscript.py & On Sep 1, 2012, at 11:29 PM, Michael Lewis wrote: > Hi everyone, > > I am sorry to ask this when there are a lot of resources online regarding the > subject, but I've spent the past two days trying to figur

[Tutor] Running a script in the background

2012-09-01 Thread Michael Lewis
Hi everyone, I am sorry to ask this when there are a lot of resources online regarding the subject, but I've spent the past two days trying to figure this out and I don't get it. I have a script that will run forever. Since it runs forever, I don't want to see the interpreter or command line. I w

Re: [Tutor] using multiprocessing efficiently to process large data file

2012-09-01 Thread Wayne Werner
On Thu, 30 Aug 2012, Abhishek Pratap wrote: Hi Guys I have a with few million lines. I want to process each block of 8 lines and from my estimate my job is not IO bound. In other words it takes a lot more time to do the computation than it would take for simply reading the file. I am wondering

Re: [Tutor] Why begin a function name with an underscore

2012-09-01 Thread Wayne Werner
On Thu, 30 Aug 2012, Steven D'Aprano wrote: On 28/08/12 21:24, Wayne Werner wrote: On Mon, 27 Aug 2012, Richard D. Moores wrote: What the best way to test if something's an integer? try: whatever_you_want(supposed_integer) except ValueError: print("Oops, that wasn't an integer! Ple

Re: [Tutor] List all possible 10digit number

2012-09-01 Thread eryksun
On Sat, Sep 1, 2012 at 3:18 AM, Dave Angel wrote: > > Somehow i missed the point that xrange() is NOT necessarily limited to > Python int values. So it may be usable on your machine, if your Python > is 64bit. All I really know is that it works on mine (2.7 64bit, on > Linux). See the following qu

Re: [Tutor] Tutor Digest, Vol 102, Issue 98

2012-09-01 Thread Mark Lawrence
On 01/09/2012 01:20, Steven D'Aprano wrote: On 31/08/12 18:31, Mark Lawrence wrote: On 31/08/2012 04:27, William R. Wing (Bill Wing) wrote: How about - for item in iter(list): ….print item Overengineering? :) A list is an iterator. Technically, no it isn't, it is an "iterable" or a "seq

Re: [Tutor] List all possible 10digit number

2012-09-01 Thread Dave Angel
On 08/31/2012 09:08 PM, Scurvy Scott wrote: > First of all thank you guys for all your help. The manual is really no > substitute for having things explained in laymans terms as opposed to a > technical manual. > > My question is this- I've been trying for a month to generate a list of all > pos