[Tutor] Do not understand code snippet from "26.8. test — Regression tests package for Python"

Alan Gauld alan.gauld at yahoo.co.uk
Mon Apr 17 02:33:09 EDT 2017


On 17/04/17 05:01, boB Stepp wrote:

> Am I missing anything?  If not, then why did the code snippet use the
> (I believe to be misleading.) class variable approach with "func =
> mySuperWhammyFunction" and "self.func(self.arg)"?

I suspect it was a slightly broken attempt at reuse in that
you can assign other functions to the class variable func.
In your code the function is hard coded into the test_func()
method. The original code (apart from using self.func) allowed
the mixin func attribute to be reset to different functions.

But I'm guessing at the authors intent, it may just have
been over-engineering...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list