function factory question: embed current values of object attributes
Alan Isaac
aisaac at american.edu
Fri Feb 20 13:49:21 EST 2009
More information about the Python-list mailing list
Fri Feb 20 13:49:21 EST 2009
- Previous message (by thread): Find the location of a loaded module
- Next message (by thread): function factory question: embed current values of object attributes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have a class `X` where many parameters are set at instance initialization. The parameter values of an instance `x` generally remain unchanged, but is there way to communicate to a method that it depends only on the initial values of these parameters (and does not need to worry about any changes)? The behavior of method `m` depends on these parameter values. It turns out `m` gets called a lot, which means that the pameter values are accessed over and over (self.p0, self.p1, etc). I would like to manufacture a function equivalent to the method that simply uses fixed values (the values at the time it is manufactured). I do not care if this function is attached to `x` or not. I have a feeling that I am turning something simple into something complex, perhaps for lack of an afternoon coffee or lack of CS training. Suggestions appreciated. Alan Isaac
- Previous message (by thread): Find the location of a loaded module
- Next message (by thread): function factory question: embed current values of object attributes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list