On Jan 14, 7:49 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> Mark wrote:[a lot of valid, but long concerns about types that return
>  an object of their own type from some of their methods]
>
> I think that the best solution is to use an alternative constructor
> in your arithmetic methods. That way users don't have to learn about
> two different factories for the same type of objects. It also helps
> with subclassing, because users have to override only a single method
> if they want the results of arithmetic operations to be of their own
> type.

Aha.  I was wondering whether __new__ might appear in the solution
somewhere, but couldn't figure out how that would work;  I'd previously
only ever used it for its advertised purpose of subclassing immutable
types.

> Hope this helps,

It helps a lot.  Thank you.

Mark

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to