Re: [Tutor] os.system() not working
Hello, On 2013-08-27 16:03, Nitish Kunder wrote: I have a python program which i am calling from a php script. The arguments to the program is a path to the file The program when directly run from console executes normally. But when I try to execute the program from browser ie call the python script from php, os.system command is not working what might be the problem. Your question is lacking some context, like Alan already mentioned, but my first suspicions would be: - Relying on a PATH that doesn't exist/is not as you expect in that environment - Relying on a working directory that turns out to not be what you expected pgpYrKxQgRu70.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] os.system() not working
Hi, in any case and apart from what was already said, your setup sounds very awkward, if not insane. Are you sure your implementation is a good idea? -nik Nitish Kunder ndk1...@gmail.com schrieb: Hii I have a python program which i am calling from a php script. The arguments to the program is a path to the file The program when directly run from console executes normally. But when I try to execute the program from browser ie call the python script from php, os.system command is not working what might be the problem. Thanks ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] os.system() not working
On Tue, Aug 27, 2013 at 6:33 AM, Nitish Kunder ndk1...@gmail.com wrote: Hii I have a python program which i am calling from a php script. The arguments to the program is a path to the file The program when directly run from console executes normally. But when I try to execute the program from browser ie call the python script from php, os.system command is not working what might be the problem. Thanks Due to the lack of context I am forced to think you must be slightly confused. PHP is not Python. Thus your PHP script can not execute the os.system() function, because it does not exist in PHP, only in Python. PHP equivalent would be exec() at least as far as I know, but use it carefully and with caution. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] os.system() not working
On 2013-08-28 08:16, wolfrage8...@gmail.com wrote: PHP is not Python. You misread. I have a python program which i am calling from a php script. pgpqqKjmHTR5l.pgp Description: PGP signature ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] spss.BasePivotTable
From: Steven D'Aprano st...@pearwood.info To: tutor@python.org Sent: Wednesday, August 28, 2013 4:19 AM Subject: Re: [Tutor] spss.BasePivotTable On 27/08/13 23:14, Albert-Jan Roskam wrote: Hello, I am trying to create a BasePivot table with three columns: one for the labels, one for a a category Before and one for After. The following attempt fails, but what am I doing wrong? At least two things. Here is the first: try: [much code] except spss.SpssError: print Error. You should replace that line with: print Python gives you a nice traceback showing you exactly what went wrong and where it went wrong, but I'm not going to show it to you. Instead, you have to guess, because Screw You. It's a little more wordy, but more accurate. ;-) Thank you, I entirely agree. I hate nondescriptive errors myself, too. And the second: print spss.GetLastErrorMessage() You're apparently not reading what the last error message is, or if you have read it, you're keeping it a secret from us. What you actually ought to do is preferably get rid of the try...except altogether, at least while debugging. Your aim as a programmer is not to hide errors, but to eliminate them. Hiding them only makes it harder to identify the errors, which is the first step in eliminating them. I was also thinking that there was a bit MUCH code in the try-except. But sometimes I keep it all in a try-clause because these lines of code are one coherent block. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Fwd: Need help returning a null/blank value when using string indexes
Hi, This is my first time asking for help on this list, so I welcome constructive criticism about how to make my question clearer. AND I'm thankful that I found this list! Here's my issue: Below the line, I've copied and pasted an assignment. This isn't homework -- it's practice on a Udacity (free online course) as I'm learning Python. I've written it out and gotten it almost correct except for Test Case 3. All the other problem sets give you the answers, but this one was suggested from a student in the class and there was no given solution that I could use to see where I'm going wrong. Which brings me to you all. The task asks me to assign something to variables part1, part2, and part3 using the given variables fragA, fragB, and fragC. Everything works except that I can't seem to give part2 the right assignment to produce Ucity. I've gotten this far as an assignment for part2: part2 = (fragA[-7:-5] + '') But it asks me to use a string, not a blank space. part2 needs begin with 'da' so I can produce 'Udacity' in Test Case 2, but needs to somehow end with a null kind of value so I can produce 'Ucity' in Test Case 3. See below for the complete assignment, in comments, for more clarity in what's going on: (By the way, the commented out bit at the end is just my notes to help steer me in the right direction). _ # Write one line of Python code that uses # only the variables fragA, fragB, and fragC # to satisfy the given test cases. # If you are not sure how multiple assignments and # string slicing works, check out the links to # additional tutorials in Instructor Comments # under this exercise! fragA, fragB, fragC = 'supercalifragilisticexpialudacious', \ 'SUPERMAN', 'ytiroirepus' ### WRITE MULTIPLE ASSIGNMENT HERE ### ### THIS MUST BE ONE LINE ### part1, part2, part3 = fragB[1], (fragA[-7:-5] + ''), (fragA[5] + fragC[2] + fragC[1] + fragC[0]) ### TEST CASES. PRESS RUN TO TEST ### deadline = part1 + part2[0:2] + part3[-1] print Test case 1 (Uday): , deadline == 'Uday' fixed = part1 + part2 + part3 print Test case 2 (Udacity): , fixed == 'Udacity' destination = part1 + part2[-1] + part3 print Test case 3 (Ucity): , destination == 'Ucity' #part1, part2, part3 = fragB[1], fragA[-7:-5], fragC[0] #deadline #part3 = y #part2 = da #part1 = U #part1, part2, part3 = fragB[1], fragA[-7:-5], ('c' + fragC[2] + fragC[1] + fragC[0]) #fixed #part3 = city #part2 = da #part1 = U #part1, part2, part3 = fragB[1], fragA[-7:-5], fragC[0] #destination #part3 = city #part2 = da' ' #part1 = U Thank you kindly! Robyn ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fwd: Need help returning a null/blank value when using string indexes
On 27/8/2013 22:41, Robyn Perry wrote: part2 = (fragA[-7:-5] + '') But it asks me to use a string, not a blank space. part2 needs begin with 'da' so I can produce 'Udacity' in Test Case 2, but needs to somehow end with a null kind of value so I can produce 'Ucity' in Test Case 3. See below for the complete assignment, in comments, for more clarity in what's going on: It's been so long since I've seen such a nonsensical assignment. However, I can point out a few things that might clarify it for you, as you've presumably seen the entire assignment. If you're trying to produce destination from part1, part2, and part3, I don't know why you don't just use part1 + part3 If you're required somehow to use all three variables, then you can just use part1 + part2[0:0] + part3 There's no need to have a null value within part2. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor