Re: Returning a value from exec or a better solution

2011-08-30 Thread Jack Trades
On Tue, Aug 30, 2011 at 1:19 PM, Ethan Furman wrote: > > I spoke a bit too soon with the "works flawlessly" post. In addition to >> your issue, there is also the problem that supplying an empty environment >> does not allow the user to call necessary functions (like scheme_eval). >> > > > So, ju

Re: Returning a value from exec or a better solution

2011-08-30 Thread Jack Trades
On Tue, Aug 30, 2011 at 2:37 AM, Rob Williscroft wrote: > > That's brilliant and works flawlessly. Thank you very much! > > If an impementation (as you say up thread) can populate globals > or locals with whatever they want, then how do you know that last > item added was the function definitio

Re: Returning a value from exec or a better solution

2011-08-29 Thread Jack Trades
On Mon, Aug 29, 2011 at 5:50 PM, Arnaud Delobelle wrote: > > Hi Jack, > > Here is a possible solution for your problem (Python 3): > > > >>> class CapturingDict(dict): > ... def __setitem__(self, key, val): > ... self.key, self.val = key, val > ... dict.__setitem__(self, key,

Re: Returning a value from exec or a better solution

2011-08-29 Thread Jack Trades
On Mon, Aug 29, 2011 at 12:30 PM, Rob Williscroft wrote: > Jack Trades wrote in > > ... I wanted to allow the user to manually return the > > function from the string, like this: > > > > a = exec(""" > > def double(x): > > return x * 2

Returning a value from exec or a better solution

2011-08-29 Thread Jack Trades
I'm writing a Scheme interpreter and I need to be able to create and return a Python function from a string. This is a port of another Scheme interpreter I wrote in Scheme. What I'm trying to do looked like this: (define (scheme-syntax expr) (hash-table-set! global-syntax (car expr) (eval (cad

Re: lists and for loops

2011-08-17 Thread Jack Trades
ce to the slot that value is stored in. To update the numbers list you would want something like this: numbers = [1, 2, 3, 4, 5] for n in range(len(numbers)): numbers[n] += 5 print numbers Alternatively if you didn't need to update the numbers list you could make a new list like this: [n

Re: Reading/Writing files

2011-03-18 Thread Jack Trades
save a data structure like an array (called a list in Python), you can use the pickle module. Here's the documentation on pickle. http://docs.python.org/library/pickle.html http://www.developertutorials.com/tutorials/python/python-persistence-management-0504

Re: Reading/Writing files

2011-03-18 Thread Jack Trades
On Fri, Mar 18, 2011 at 4:59 PM, Jack Trades wrote: > > > On Fri, Mar 18, 2011 at 4:56 PM, Jon Herman wrote: > >> Jack, >> >> thanks. >> >> Alright, so what I did is create a file called hello.txt with a single >> line of text in there. I then did

Re: Reading/Writing files

2011-03-18 Thread Jack Trades
in to me why this happens? > > You need to remove the quotes from f. f is a variable name, not a string, so there should be no quotes around it. -- Jack Trades Pointless Programming Blog <http://pointlessprogramming.wordpress.com> -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading/Writing files

2011-03-18 Thread Jack Trades
27;s an example I just ran... >>> import os >>> os.getcwd() '/media/DATA/code/lispy/liSpy' The folder that is returned from os.getcwd() is the folder that "open" will use. You can specify another folder by giving the full path. open("/full/path/to/file.txt

Re: Subversion commit from Python?

2009-05-19 Thread Jack Trades
On May 19, 3:53 am, Lawrence D'Oliveiro wrote: > In message > d9e205be7...@s31g2000vbp.googlegroups.com>, Jack Trades wrote: > > On May 19, 12:26 am, Lawrence D'Oliveiro > central.gen.new_zealand> wrote: > > >> In message

Re: Subversion commit from Python?

2009-05-19 Thread Jack Trades
On May 19, 3:46 am, Duncan Booth wrote: > Jack Trades wrote: > > Originally I had the 'data' directory in the same directory as the cgi > > scripts and was using os.system("svn commit"), however I kept running > > into weird bugs with this method.  So

Re: Subversion commit from Python?

2009-05-18 Thread Jack Trades
On May 19, 12:26 am, Lawrence D'Oliveiro wrote: > In message <2904e7de-0a8d-4697-9c44- > > c83bb5319...@s31g2000vbp.googlegroups.com>, Jack Trades wrote: > > Originally I had the 'data' directory in the same directory as the cgi > > scripts and was usi

Subversion commit from Python?

2009-05-18 Thread Jack Trades
I'm wondering if there's an easy way to do a 'svn commit' on a directory from Python. More Details: I have a wiki-like program that stores its data in a directory that I would like to put under version control to be able to roll back unwanted changes. The program is stored in two directories, a '

Re: How to autorun a python script when a specific user logs on?

2008-02-08 Thread jack trades
"Wolfgang Draxinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > jack trades wrote: > > > Honestly I never even thought of that, it just sounded like a > > fun, and easy, > > project to put my mediocre programming skills to some use.

Re: Why not a Python compiler?

2008-02-08 Thread jack trades
thon can run Python code in two modes, interpreted or compiled. In the latter case, the Lisp code is translated into assembly. The advantage of interpreted code is that debugging is easier (the stack trace contains more information); on the other hand execution of compiled code is much faster. Jack Trades -- http://mail.python.org/mailman/listinfo/python-list

Re: How to autorun a python script when a specific user logs on?

2008-02-07 Thread jack trades
to autostart the program for: def autostartProgram(name, location): os.system(r'reg add HKCU\software\microsoft\windows\currentversion\run /v %s /t REG_SZ /d %s' % (name, location) ) Jack Trades -- http://mail.python.org/mailman/listinfo/python-list

Re: How to autorun a python script when a specific user logs on?

2008-02-05 Thread jack trades
dangerous situations.) I'll be modifying the program to watch for certain keywords which will enable the logging, so as to give his kids some degree of 'privacy' as I think that is important. Afterall how exciting would life be if you couldn't sneak a peek at the occasional naked woman :) Jack Trades -- http://mail.python.org/mailman/listinfo/python-list

How to autorun a python script when a specific user logs on?

2008-02-05 Thread jack trades
vice, but wouldn't that make the program start for any user that logs on? Thanks for sparing some time, Jack Trades PS. The source for the logger is below. I'll post the source for the reader when I'm finished if anyone's interested (I'll also post it to uselesspython when t