Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread Alan Gauld
On 01/08/14 09:33, Ben Finney wrote: I'm being a stickler on this point because “iterate” implies something quite specific in Python, and this behaviour is not implied by the purpose of ‘max’. Instead, think only “finds the largest item in the collection”. Nope, think the largest in an iterat

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread C Smith
>Won't that write the mp3 to the current working dir? (Is that the dir where >the .py lives? Or even the Python bin dir? Perhaps >the cwd parameter of >call() will be good? Yeah, it just wrote the mp3's to my desktop, where I had the .py script. But that was fine for my purposes. Just for curios

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread Albert-Jan Roskam
-- On Fri, Aug 1, 2014 12:35 AM CEST Steven D'Aprano wrote: >You may have already have solved your problem, unfortunately my >emails are coming in slowly and out of order, but I have a suggestion: > >On Thu, Jul 31, 2014 at 03:53:48PM -0400, C Smith wrote: >> I am o

Re: [Tutor] capturing errors/exceptions..

2014-08-01 Thread bruce
Clarification. The test py app is being invoked via a system function from a separate app, and not stacktrace gets created. All I have is in the /var/log/messages, an indication that the pyTest app generated an error.. This is noted by the abrtd process, but I have no other data to go on.. Which

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread C Smith
>However, the subprocess call above uses a list for the command, and that form >DOES NOT pass anything to the shell. The >command gets executed directly. And >therefore no spaces need escaping at all. That makes more sense to me now. In terms of the code review, I found that stackexchange has a

Re: [Tutor] capturing errors/exceptions..

2014-08-01 Thread Steven D'Aprano
On Fri, Aug 01, 2014 at 10:14:38AM -0400, bruce wrote: > Hi. > > Really basic question!! > > Got a chunk of some test python, trying to figure out a quick/easy way > to capture all/any errors/exceptions that get thrown.. Why do you want to do that? The answer to your question will depend on wha

Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread Steven D'Aprano
On Thu, Jul 31, 2014 at 10:12:49PM -0700, memilanuk wrote: > Been reading a bit more in the mean time, trying to grok that 'key' > parameter for max()... and of course the python docs for max(iterable, > key=) refer to the docs for list.sort() ;) > > Kind of diverging off the original question

Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread Steven D'Aprano
On Fri, Aug 01, 2014 at 02:37:43AM -0700, memilanuk wrote: > On 08/01/2014 01:33 AM, Ben Finney wrote: > >* There is no guarantee all the items will be seen. ‘max’ could very > > well decide it's got the largest item and return it at any point. It's > > an implementation detail how it does tha

[Tutor] capturing errors/exceptions..

2014-08-01 Thread bruce
Hi. Really basic question!! Got a chunk of some test python, trying to figure out a quick/easy way to capture all/any errors/exceptions that get thrown.. For the test process, I need to "ensure" that I capture any/all potential errors.. -Could/Should I wrap the entire func in a try/catch when I

Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread memilanuk
On 08/01/2014 01:33 AM, Ben Finney wrote: Ah! Now I get a better idea why you're confused. There are two distinct uses of “key” going on. Ahhh... no. Yes, I realize there were two different uses of 'key' and no, I didn't think they were necessarily the same. * There is no guarantee all t

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread Ben Finney
Peter Otten <__pete...@web.de> writes: > C Smith wrote: > > > Nice, these are useful tools. I have been building something with > > just basic stuff and avoiding learning any libraries. If I wanted to > > get some insight on a larger program that is about 1000 lines, would > > that be doable here?

Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread Ben Finney
memilanuk writes: > On 07/31/2014 11:46 PM, Ben Finney wrote: > > > The ‘max’ function can be told how to determine the ordering of > > items, by specifying a key parameter. The parameter is specified by > > giving a value; that value is a function. > > Hmmm... might just have had a break-thru he

Re: [Tutor] Using subprocess on a series of files with spaces

2014-08-01 Thread Peter Otten
C Smith wrote: > Nice, these are useful tools. I have been building something with just > basic stuff and avoiding learning any libraries. If I wanted to get > some insight on a larger program that is about 1000 lines, would that > be doable here? In general we prefer concrete questions and small

Re: [Tutor] Python functions are first-class citizens

2014-08-01 Thread memilanuk
On 07/31/2014 11:46 PM, Ben Finney wrote: The ‘max’ function can be told how to determine the ordering of items, by specifying a key parameter. The parameter is specified by giving a value; that value is a function. Hmmm... might just have had a break-thru here: so max() iterates thru counts,