On Mon, 2009-07-13 at 22:59 -0400, Paul Lussier wrote:
Lloyd Kvam pyt...@venix.com writes:
You've already gotten two useful responses. I'd just like to add that
typically, the object attributes are referenced directly:
rect.length * rect.width
Lloyd, thanks. But what if the
Lloyd Kvam pyt...@venix.com writes:
If the value will be computed on demand, __getattr__ is one way to go.
def __getattr__(self, attr):
if attr == 'foo':
return self.compute_foo()
elif
else:
raise
On Tue, 2009-07-14 at 15:32 -0400, Joshua Judson Rosen wrote:
The simplistic self.foo = self.compute_foo() will trigger a call to
__getattr__, so you can't use that within __getattr__.
That's not true; it *will*, however, trigger a call to __settattr__,
if it exists; that's what you're
On Sat, 2009-07-11 at 23:44 -0400, Paul Lussier wrote:
How do I create dynamically created methods in python classes?
For example, if I have a number of member variables which I want to
get
or set, I don't want to have to create getters and setters for each
attribute, since the code would
On 07/11/2009 11:44 PM, Paul Lussier wrote:
In perl, I can use the AUTOLOAD feature to dynamically create methods,
something like this:
It looks like in perl6 you get this for free. I'm just getting started
with it though.
-Bill
--
Bill McGonigle, Owner Work: 603.448.4440
BFC
Lloyd Kvam pyt...@venix.com writes:
You've already gotten two useful responses. I'd just like to add that
typically, the object attributes are referenced directly:
rect.length * rect.width
Lloyd, thanks. But what if the attribute isn't set yet? If I have
self.foo, and self.foo
Paul Lussier p.luss...@comcast.net writes:
Hi Folks,
How do I create dynamically created methods in python classes?
For example, if I have a number of member variables which I want to get
or set, I don't want to have to create getters and setters for each
attribute, since the code would
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
On 07/11/09 23:44, quoth Paul Lussier:
Hi Folks,
How do I create dynamically created methods in python classes?
For example, if I have a number of member variables which I want to get
or set, I don't want to have to create getters and setters
Hi Folks,
How do I create dynamically created methods in python classes?
For example, if I have a number of member variables which I want to get
or set, I don't want to have to create getters and setters for each
attribute, since the code would largely be the same, just the variable
I'm dealing