Re: [Tutor] Testing print

2016-09-30 Thread boB Stepp
On Sat, Oct 1, 2016 at 12:12 AM, Richard Doksa wrote: > unsubscibe please If you wish to unsubscribe, go to the bottom of this page and follow its instructions: https://mail.python.org/mailman/listinfo/tutor boB ___ Tutor maillist - Tutor@python.or

Re: [Tutor] Testing print

2016-09-30 Thread boB Stepp
On Fri, Sep 30, 2016 at 5:07 AM, Steven D'Aprano wrote: [snip] > and preferably three: > > (1) function that does the calculation; > (2) function that does the output; > (3) function that calls (1) and then (2) > > > If (1) and (2) are well-designed, then (3) is so trivial it needs no > tests: >

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread Ben Finney
boB Stepp writes: > I think this was my key point of confusion. I was mistakenly thinking > of f(x) as referring to the function object. Right. ‘f’ is an expression, that Python resolves as whatever object ‘f’ references. ‘f(x)’ is an expression, that Python resolves by *calling* the object r

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread boB Stepp
On Fri, Sep 30, 2016 at 6:55 AM, Steven D'Aprano wrote: > On Thu, Sep 29, 2016 at 09:43:57PM -0500, boB Stepp wrote: >> But why does Python require >> separating the function object from its parameters when it is being >> passed as an argument to another function? > > If you pass the function arg

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread boB Stepp
On Fri, Sep 30, 2016 at 3:43 AM, Alan Gauld via Tutor wrote: > On 30/09/16 03:43, boB Stepp wrote: > >> Also, I note that if I just type a function name without the >> parentheses in the interpreter, I will get something like this: >> > def f(): >>pass >> > f >> >> >> So the i

Re: [Tutor] Testing print

2016-09-30 Thread boB Stepp
On Fri, Sep 30, 2016 at 5:07 AM, Steven D'Aprano wrote: > On Thu, Sep 29, 2016 at 09:24:51PM -0500, boB Stepp wrote: >> Second, it seems that prints are often intermingled with the main >> logic of a function and only serve to pass on a message to the user. > > Yeah, you normally shouldn't do tha

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread Steven D'Aprano
On Fri, Sep 30, 2016 at 09:43:47AM +0100, Alan Gauld via Tutor wrote: > On 30/09/16 03:43, boB Stepp wrote: > > > Also, I note that if I just type a function name without the > > parentheses in the interpreter, I will get something like this: > > > def f(): > >pass > > > f

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread Steven D'Aprano
On Thu, Sep 29, 2016 at 09:43:57PM -0500, boB Stepp wrote: > I believe I understand the barebone mechanics on how to do this. But > I do not understand the rationale of why Python does it the way it > does. Say > > def f(g, *args): > g(*args) Right. This says: - Define a function called "

Re: [Tutor] Testing print

2016-09-30 Thread Steven D'Aprano
On Thu, Sep 29, 2016 at 09:24:51PM -0500, boB Stepp wrote: > Testing output of print functions (Py 3). First off, is it worth it to do so? Unless you are writing tests for the Python language itself, you can assume that print() itself is working. You should test functions that call print: call

Re: [Tutor] Passing functions as arguments to other functions

2016-09-30 Thread Alan Gauld via Tutor
On 30/09/16 03:43, boB Stepp wrote: > Also, I note that if I just type a function name without the > parentheses in the interpreter, I will get something like this: > def f(): >pass > f > > > So the impression I am getting is that a function name by itself (with > no pare