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'
Lloyd Kvam writes:
>
> On Mon, 2009-07-13 at 22:59 -0400, Paul Lussier wrote:
> > Lloyd Kvam 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
> >
> > Ll
Lloyd Kvam 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 AttributeError( attr +
On Mon, 2009-07-13 at 22:59 -0400, Paul Lussier wrote:
> Lloyd Kvam 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
Lloyd Kvam 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 hasn't yet been set
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 Com
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 wo
-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 set
Paul Lussier 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 largely be the
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
10 matches
Mail list logo