[Tutor] question about OOP (or just grammer thing) ?

Geonjae Lee gjlee@seri.co.uk
Fri, 28 Jun 2002 09:15:36 +0100


Hi I'm a python newbie.
I'm studying Tkinter.
And All I know about programming language was C.
That means I'm also not used to the OOP concept.

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

from Tkinter import *

class HelloButton(Button):
    def __init__(self, parent=3DNone, **config):
        Button.__init__(self, parent, config)
        self.pack()
        self.config(command=3Dself.callback)

    def callback(self):
        print 'Goodbye world...'
        self.quit()

if __name__ =3D=3D '__main__':
    HelloButton(text=3D'Hello subclass world').mainloop()

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

I'm reading Programming Python 2nd edition published by O'reilly and
also struggle to understand concept of class.=20

1. In the above example, variable named 'config' is used in 3 places.=20
Are they all same or different?

2. I guess they're not all same.=20
    def __init__(self, parent=3DNone, **config):
        Button.__init__(self, parent, config)

I guess variable config in above 2 lines are same one.
If then, why '**config' is used in __init__ method ?=20
And I tried to use just 'config' instead of '**config', but that caused
a error.


Thanks in advance.
ThomasLee (KJ Lee)