[Tutor] OOP clarification needed

Jim Byrnes jf_byrnes at comcast.net
Tue Jun 1 22:19:17 CEST 2010

Whenever I teach myself a new language I have great difficulty 
understanding the nuts and bolts of it's OO implementation. Compared to 
some older procedural languages I always end up becoming confused by the 
large number of built in methods.  When reading through code examples I 
many times get hung up on trying to figure out just where some methods 
come from.

Case in point is this code snippet from a chapter on Tkinter.

def viewer(imgdir, kind=Toplevel, cols=None):
     make thumb links window for an image directory:
     one thumb button per image; use kind=Tk to show
     in main  app window, or Frame container (pack);
     imgfile differs per loop: must save with a default;
     photoimage objs must be saved: erased if reclaimed;
     win = kind()
     win.title('Viewer: ' + imgdir)
     thumbs = makeThumbs(imgdir)

What is the relationship between kind=Toplevel in the first line and 
win=kind() further down.  Isn't "kind" a variable and "kind()" a method? 
  I've probable overlooked something fundamental but  a explanation 
would be appreciated.

Regards, Jim

More information about the Tutor mailing list