[Tutor] Testing print

boB Stepp robertvstepp at gmail.com
Sat Oct 1 11:31:58 EDT 2016


On Sat, Oct 1, 2016 at 2:02 AM, Alan Gauld via Tutor <tutor at python.org> wrote:

> Do you need print_msgs()?
> Won't it work the same with
>
>            print(right_justify(input_string))
>
> You are only feeding one line at a time into the print msgs.
>
> You could do it all in a new print_msgs() like:
>
> def print_msgs(formatter, msgs):
>     for msg in msgs:
>         print(formatter(msg))
>
> And main() reduces to
>
> def main():
>     print_msgs(right_justify, input_strings)

I have to say this thought you gave ties in nicely with the other
thread ([Tutor] Passing functions as arguments to other functions) I
started in parallel with this one.  A practical example of passing a
function to another function...



-- 
boB


More information about the Tutor mailing list