Overloading operators

Mr.SpOOn mr.spoon21 at gmail.com
Thu Oct 16 23:47:55 CEST 2008

On Thu, Oct 16, 2008 at 10:54 PM, Lie Ryan <lie.1296 at gmail.com> wrote:
> On Wed, 15 Oct 2008 14:34:14 +0200, Mr.SpOOn wrote:
> Something that is more pythonic is something that doesn't use
> multimethods. It's just an elaborated way to do type checking. In python,
> you usually avoid type checking and if-elif-block-with-isinstance in
> favor of Duck Typing and EAFP (Easier to Ask Forgiveness than Permission,
> i.e. try-block).

Well, yes... I actually changed my mind. I didn't have so much types
to working with, so the if-elif block is ok. But I was curious to know
if there was a "better" way.

> *smells a bad class design* If that is the case, I'd recommend on
> splitting that behavior into two or more functions/operators (or possibly
> splitting the class). It's hard to reason the behavior of a class if the
> class is that complex (Simple is better than complex; Complex is better
> than complicated. The Zen of Python this:2-3).

Mmm, yes, maybe it was a bad design. Not sure. Anyway I changed it :D

More information about the Python-list mailing list