Re: [Tutor] Running a script in the background (offshoot - sorry, OP)

2012-09-02 Thread Ray Jones
On 09/02/2012 06:03 PM, Steven D'Aprano wrote: > On Sun, Sep 02, 2012 at 03:14:53PM -0700, Ray Jones wrote: >> This is only tangentially related to the thread. Someone mentioned that >> so long as a script didn't require user input or output to the user, it >> could run silently in the background.

Re: [Tutor] Running a script in the background (this time Cc'd to the list)

2012-09-02 Thread eryksun
On Sun, Sep 2, 2012 at 9:04 PM, William R. Wing (Bill Wing) wrote: > > Apple's mechanism for launching applications at login is picky > about what it will accept as a legitimate application to add to > the list. Here's an Ask Different (Apple Stack Exchange) answer with a template for a launchd

Re: [Tutor] Running a script in the background (this time Cc'd to the list)

2012-09-02 Thread William R. Wing (Bill Wing)
On Sep 2, 2012, at 6:15 PM, Alan Gauld wrote: > On 02/09/12 21:30, William R. Wing (Bill Wing) wrote: > >> My suggestion would be to take the script and run it through py2app, >> which will turn it into a stand-alone application which can then >> be added to your list of StartUp or LogIn applica

Re: [Tutor] Running a script in the background

2012-09-02 Thread Steven D'Aprano
On Sun, Sep 02, 2012 at 03:14:53PM -0700, Ray Jones wrote: > This is only tangentially related to the thread. Someone mentioned that > so long as a script didn't require user input or output to the user, it > could run silently in the background. But is there a way for a Python > (2.7.3) script to

Re: [Tutor] Running a script in the background

2012-09-02 Thread Ray Jones
On 09/02/2012 03:30 PM, Alan Gauld wrote: > On 02/09/12 23:14, Ray Jones wrote: >> could run silently in the background. But is there a way for a Python >> (2.7.3) script to determine whether it was called by the user or called >> by something like cron or kalarm? That way user inputs could be used

Re: [Tutor] Running a script in the background

2012-09-02 Thread Alan Gauld
On 02/09/12 23:14, Ray Jones wrote: could run silently in the background. But is there a way for a Python (2.7.3) script to determine whether it was called by the user or called by something like cron or kalarm? That way user inputs could be used when called by a user, but defaults could be used

Re: [Tutor] Running a script in the background

2012-09-02 Thread Ray Jones
This is only tangentially related to the thread. Someone mentioned that so long as a script didn't require user input or output to the user, it could run silently in the background. But is there a way for a Python (2.7.3) script to determine whether it was called by the user or called by something

Re: [Tutor] Running a script in the background

2012-09-02 Thread William R. Wing (Bill Wing)
On Sep 2, 2012, at 5:06 PM, Michael Lewis wrote: > > > Michael, I see you have several Windows answers, but it doesn't look as > though you found quite what you were hoping for on OSX. My suggestion would > be to take the script and run it through py2app, which will turn it into a > stand-a

Re: [Tutor] Running a script in the background

2012-09-02 Thread Michael Lewis
> > > > Michael, I see you have several Windows answers, but it doesn't look as > though you found quite what you were hoping for on OSX. My suggestion > would be to take the script and run it through py2app, which will turn it > into a stand-alone application which can then be added to your list

Re: [Tutor] Fwd: Running a script in the background

2012-09-02 Thread eryksun
On Sun, Sep 2, 2012 at 10:06 AM, Walter Prins wrote: > > nohup python myscript.py & > > Then you can close the terminal afterwards. "nohup" means"no hangup". > It tells the system that the python process launched as a result of > this command should not be terminated when its parent shell is > t

Re: [Tutor] Running a script in the background

2012-09-02 Thread William R. Wing (Bill Wing)
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 figure this out and I > don't get it. > > I have a script that will run forever. Since it ru

Re: [Tutor] making len() and __len__ return a non-int

2012-09-02 Thread Dave Angel
On 09/02/2012 03:06 PM, Albert-Jan Roskam wrote: > Albert-Jan Roskam wrote: > If you're not going to put anything of your own into the reply message, please delete all the context you're not responding to, and then delete the message instead of sending. On the other hand, if the message actuall

Re: [Tutor] making len() and __len__ return a non-int

2012-09-02 Thread Albert-Jan Roskam
Albert-Jan Roskam wrote: > >> If I implement __len__ in my own class, does it really have to return an >> int? Is there no way around this (other than modifying the source code of >> python itself ;-) It would be nice if len(Example(row, col)) would return >> a dictionary, or a two-tuple (see code

[Tutor] Fwd: Running a script in the background

2012-09-02 Thread Walter Prins
forwarding accidental reply to person only -- Forwarded message -- From: Walter Prins Date: 2 September 2012 15:05 Subject: Re: [Tutor] Running a script in the background To: Michael Lewis On 2 September 2012 05:00, Michael Lewis wrote: > >> For windows not sure but for osx j

Re: [Tutor] making len() and __len__ return a non-int

2012-09-02 Thread Peter Otten
Albert-Jan Roskam wrote: > If I implement __len__ in my own class, does it really have to return an > int? Is there no way around this (other than modifying the source code of > python itself ;-) It would be nice if len(Example(row, col)) would return > a dictionary, or a two-tuple (see code below

Re: [Tutor] 2.7.3 generator objects

2012-09-02 Thread Peter Otten
Steven D'Aprano wrote: > On 02/09/12 17:09, Ray Jones wrote: > >> But didn't I read somewhere that you can reset an iterator to go through >> the whole process again? > > In general, no. > > The usual way to "reset" an iterator is to re-create it. > > > walker = os.walk("/home/steve/start") >

[Tutor] making len() and __len__ return a non-int

2012-09-02 Thread Albert-Jan Roskam
Hi,   If I implement __len__ in my own class, does it really have to return an int? Is there no way around this (other than modifying the source code of python itself ;-) It would be nice if len(Example(row, col)) would return a dictionary, or a two-tuple (see code below). The strange thing is t

Re: [Tutor] 2.7.3 generator objects

2012-09-02 Thread Steven D'Aprano
On 02/09/12 17:09, Ray Jones wrote: But didn't I read somewhere that you can reset an iterator to go through the whole process again? In general, no. The usual way to "reset" an iterator is to re-create it. walker = os.walk("/home/steve/start") # ... process files in walker walker = os.walk

Re: [Tutor] 2.7.3 generator objects

2012-09-02 Thread eryksun
On Sun, Sep 2, 2012 at 3:09 AM, Ray Jones wrote: > > But didn't I read somewhere that you can reset an iterator to go through > the whole process again? You could implement that ability in your own objects, but it's not part of the protocol. I forgot to mention generator expressions. This is an

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

2012-09-02 Thread eryksun
On Sun, Sep 2, 2012 at 2:41 AM, Alan Gauld wrote: > >> if __name__ == '__main__': # <-- required for Windows > > Why? > What difference does that make in Windows? It's a hack to get around the fact that Win32 doesn't fork(). Windows calls CreateProcess(), which loads a fresh interpreter. mul

Re: [Tutor] 2.7.3 generator objects

2012-09-02 Thread Ray Jones
On 09/01/2012 11:57 PM, eryksun wrote: > To be an iterable in general, it suffices to have either an __iter__ > method or a __getitem__ method. Here are the glossary definitions: > http://docs.python.org/glossary.html#term-iterable > http://docs.python.org/glossary.html#term-iterator After a few

Re: [Tutor] 2.7.3 generator objects

2012-09-02 Thread eryksun
On Sun, Sep 2, 2012 at 1:44 AM, 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? ^_^), The output from os.walk is a generator, which is an iterator. os.walk actually calls itself recursively, creating a c