On Jul 22, 1:33 pm, Thomas Jollans <t...@jollybox.de> wrote: > On 22/07/11 13:12, caccolangrifata wrote: > > > I'm very very new with python, and I have some experience with java > > programming, so probably you guys will notice. > > Anyway this is my question: > > I'd like to use class scope vars in method parameter, something like > > that > > > class foo(object): > > > __init__(self, len = 9): > > self.__myvar = len > > > def foo2(self, len = self_myvar): > > while i < len: > > dosomething > > I think what you want to do is this: > > class foo (object): > def __init__(self, len=9): > self._len = len > def foo2(self, len=None): > if len is None: > len = self._len > # ... > > Default arguments are for when you want to use exactly the same object > each time the function/method is called. If you the object you want to > use depends on something, you can use this arg=None idiom.
Yep! Leaving aside the typos, that's exactly I want to do. Thanks! -- http://mail.python.org/mailman/listinfo/python-list