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

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri, 28 Jun 2002 07:51:34 -0700 (PDT)


> I'm reading Programming Python 2nd edition published by O'reilly and
> also struggle to understand concept of class. 
> 
> 1. In the above example, variable named 'config' is used in 3 places. 
> Are they all same or different?
> 
> 2. I guess they're not all same. 
>     def __init__(self, parent=None, **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 ? 
> And I tried to use just 'config' instead of '**config', but that caused
> a error.
> 

I wanted to add on to what the others had said.

class MyClass:
    def __init__(var):
        self.var = var

in this example we have two variables named 'var'.  When the interpreter does
its work it sees that 'self.var' is part of 'self' which is an instance of
MyClass whereas 'var' is only in the local scope.