Passing data attributes as method parameters

Panos Laganakos panos.laganakos at gmail.com
Sun Apr 23 19:27:51 EDT 2006


Hello,

I'd like to know how its possible to pass a data attribute as a method
parameter.

Something in the form of:

class MyClass:
    def __init__(self):
        self.a = 10
        self.b = '20'

    def my_method(self, param1=self.a, param2=self.b):
        pass

Seems to produce a NameError of 'self' not being defined.




More information about the Python-list mailing list