Re: [Tutor] Q regarding external program calling

2016-11-05 Thread Danny Yoo
Hi Clayton, I'm not too familiar with development on Windows, unfortunately, but I think the 'subprocess' module is what you're looking for. https://docs.python.org/3/library/subprocess.html For example: http://stackoverflow.com/questions/748028/how-to-get-output-of-exe-in-python-script sh

[Tutor] Call an external program and capture its output (was: Q regarding external program calling)

2016-11-05 Thread Ben Finney
"Clayton Kirkwood" writes: > Looked all over, but haven't found the answer. Did you look in the Python standard library documentation https://docs.python.org/3/library/>? > If I have a (windows) program which I wish to start, even shell > scripts, and possibly capture the output from, how do I

[Tutor] Q regarding external program calling

2016-11-05 Thread Clayton Kirkwood
Looked all over, but haven't found the answer. If I have a (windows) program which I wish to start, even shell scripts, and possibly capture the output from, how do I do that? Thanks, C PS, also, please me to where I can find more. My searches were rather useless. _

Re: [Tutor] sumHighest function help

2016-11-05 Thread Alan Gauld via Tutor
On 05/11/16 12:07, Peter Otten wrote: > sum_highest = lambda items, n: sum(sorted(items, reverse=True)[:max(n, 0)]) > > or better: > > import heapq > > def sum_highest(items, n): > return sum(heapq.nlargest(n, items)) No, the first solution is "better" because it used lambda and slicing a

Re: [Tutor] sumHighest function help

2016-11-05 Thread Peter Otten
Lloyd Francis wrote: > I want to write a function that will calculate and return the sum of the > *n* highest value in a list *a. *Also, when n is less than 0, the answer > should be zero, and if n is greater than the number of elements in the > list, all elements should be included in the sum. >