Getting a class attribute
Oleg Broytmann
phd at phd.russ.ru
Fri Mar 24 10:24:50 EST 2000
On 24 Mar 2000, Roger Hansen wrote:
> * Oleg Broytmann
> >
> > On 24 Mar 2000, Roger Hansen wrote:
> > > def degree_sin4(self, deg, factor = self.a * math.pi/180.0, sin = math.sin):
> > > return sin(deg * factor)
> > >
> > >
> > > The question is how can I get "self.a" in degree_sin4?
> >
> > def degree_sin4(self, deg, factor = None, sin = math.sin):
> > if factor is None:
> > factor = self.a * math.pi/180.0
> > return sin(deg * factor)
> >
>
> I want to calculate factor as a default parameter value, because I
> want to speed up the method. The method will typically be called
> several thousand times. It is possible to get the class atribute "a"
> in the default function parameter?
I doubt it. It is not class attribute, it is instance attribute.
Oleg.
----
Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list