472,135 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,135 software developers and data experts.

Re: Overloading operators

On Thu, Oct 16, 2008 at 10:54 PM, Lie Ryan <li******@gmail.comwrote:
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
Oct 16 '08 #1
0 672

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by denis wendum | last post: by
2 posts views Thread by bq | last post: by
20 posts views Thread by KL | last post: by
18 posts views Thread by uday | last post: by
5 posts views Thread by Jerry Fleming | last post: by
3 posts views Thread by johnmmcparland | last post: by
15 posts views Thread by PengYu.UT | last post: by
7 posts views Thread by Rahul | last post: by
2 posts views Thread by jimzat | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.