In Python we have a wonderful facility for customizing attribute
access by defining __getattr__ or __getattribute__ in our classes.
Unfortunately (or perhaps fortunately, for reasons I don't know), this
facility only works for explicit attribute access, i.e. accessing
foo.bar. What I am in need of,
Terry Reedy wrote:
> "David Ells" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > def increment(x):
> >return x += 1
>
> 'return x+1' works better ;-)
>
> tjr
Heh, woops... thanks
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> lets say you want a generic numerical algorithom like sum
>
> Ruby
>
> def sum lst
> lst.inject(0){|total,current| total*current}
> end
>
> Java // i dont know if there is a numeric super class for numbers
>
> class Sum{
> public static int sum(int[] lst){
> int
Carl Banks wrote:
>
> I think it's kind of a fine point. In my own code I've had cases where
> I've switched from subclass to attribute and back over the development,
> and vice versa. I think there are many cases where it's preferable to
> use an attribute, but not really wrong to subclass (and
Chaz Ginger wrote:
> I was writing some code that used someone else class as a subclass. He
> wrote me to tell me that using his class as a subclass was incorrect. I
> am wondering under what conditions, if ever, does a class using a
> subclass not work.
>
> Here is an example. For instance the ori