Re: [Tutor] decorators (the "at" sign)?

2010-10-26 Thread Lie Ryan
On 10/26/10 13:46, Alex Hall wrote: > Hi all, > Now that I am able to run the source code of an open source > application I hope to one day help develop, I am trying to understand > how it works. One thing I keep seeing is an at sign followed by a > word, usually (maybe always) immediately preceedi

[Tutor] subprocess Popen PIPE error

2010-10-26 Thread Sean Carolan
What am I doing wrong here? >>> from subprocess import Popen, PIPE >>> cmd = 'ls -l' >>> p = Popen(cmd, stdout=PIPE, stderr=PIPE) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib64/python2.4/subprocess.py", line 550, in __init__ errread, errwrite) File "/usr/lib64/

Re: [Tutor] subprocess Popen PIPE error

2010-10-26 Thread Abhijeet Rastogi
Please read the documentation of Popen. You cannot pass arguments like that. >>> from subprocess import Popen,PIPE >>> import shlex >>> cmd="ls -l" >>> cmd=shlex.split(cmd) >>> p = Popen(cmd,stdout=PIPE,stderr=PIPE) or simply that means >>> p = Popen(['ls','-l'],stdout=PIPE,stderr=PIPE) Hope I

Re: [Tutor] subprocess Popen PIPE error

2010-10-26 Thread Abhijeet Rastogi
Ya. Do it using python. Why do you want to use bash when you already have python? See, do something like this:- import os alldirs = os.listdir("/path/to/dir") DIRS = [] #Only the dirs you are interested in for i in alldirs: if i.find("deploy") is -1: L.append(i) if i.find("TEMPLATE"

Re: [Tutor] Problem Passing VARs to Python from PHP & capturing return string

2010-10-26 Thread Roy Hinkelman
I am posting here as well as a PHP list since I am now getting an odd python error. Rance: Thanks for the note. I get the same error with system or exec or passthru Now, this is very strange. I made the command line string more explicit, and now it recognizes the .py script but returns a p

Re: [Tutor] Problem Passing VARs to Python from PHP & capturing return string

2010-10-26 Thread Emile van Sebille
On 10/26/2010 12:55 PM Roy Hinkelman said... I am posting here as well as a PHP list since I am now getting an odd python error. The traceback of the python error would help us diagnose the problem but it's not been included. Can you paste in the actual traceback? Emile __

[Tutor] Summing up numbers in a file

2010-10-26 Thread masawudu bature
How do I sum all occurrences of  a number in a file? I have a file with a bunch of numbers, each on it's own line: 5 3 11 3 7 3 5 5 11 7 7 ... How do i sum them up so that the output will be , 5 :  15 3 :   9 11:  22 7 :   21 ___ Tutor maillist

Re: [Tutor] Summing up numbers in a file

2010-10-26 Thread Adam Bark
On 26/10/10 21:20, masawudu bature wrote: How do I sum all occurrences of a number in a file? I have a file with a bunch of numbers, each on it's own line: 5 3 11 3 7 3 5 5 11 7 7 ... How do i sum them up so that the output will be , 5 : 15 3 : 9 11: 22 7 : 21 Assuming you know how to ite

Re: [Tutor] Summing up numbers in a file

2010-10-26 Thread Robert Berman
This certainly looks like a classroom assignment. Please make an attempt to solve the problem on your own. If the program fails, please copy the code you have written and the error messages from the traceback and someone here will be more than happy to help you work your way through the problem.

Re: [Tutor] Summing up numbers in a file

2010-10-26 Thread Emile van Sebille
On 10/26/2010 1:20 PM masawudu bature said... How do I sum all occurrences of a number in a file? I have a file with a bunch of numbers, each on it's own line: 5 3 11 3 7 3 5 5 11 7 7 ... How do i sum them up so that the output will be , 5 : 15 3 : 9 11: 22 7 : 21 Well, you'll need to

Re: [Tutor] Passing VARs to Python from PHP & capturing return string

2010-10-26 Thread Roy Hinkelman
I got it working. As several people mentioned, it was a permissions issue. When I tried the command line, I had admin access, but from the web page, I had only 'Users'. I had to manually change permissions for both the Python module 'mechanize' as well as the txt file the script was writing to. N

Re: [Tutor] Problem Passing VARs to Python from PHP & capturing return string

2010-10-26 Thread Roy Hinkelman
I am posting here as well as a PHP list since I am now getting an odd python error. Rance: Thanks for the note. I get the same error with system or exec or passthru Now, this is very strange. I made the command line string more explicit, and now it recognizes the .py script but returns a python

Re: [Tutor] problems with numdifftools

2010-10-26 Thread Bolli
Hey, First of all thanks for your response. I am also new to this forum so I expected to receive an email if somebody replies to my question. Therefore I just read it today > I am not sure if you are the right persons to contact but if not I > would appreciate a short notice and maybe an a