On Sat, Jun 9, 2012 at 1:34 PM, [email protected]
<[email protected]> wrote:
> When I asked a similar question some time ago (search on the mailing
> list) Ronan answered that both __new__ and __init__ can be used
> (__new__ is obviously necessary if you want your constructor to return
> a different class (Add(x,x)-->Mul(2,x))). Exactly because __new__ is
> obligatory sometimes most of the people choose to use it always in
> order to think less about it (not wondering when __init__ would be
> sufficient).

Hm, I see.

What I did is grepping for assignments to self._args, and, while I
can't vouch for it, it seems that such assignments (or the majority of
them) only happen in classes which are not derived from Basic.  On
other hand, I couldn't really find another way of setting self.args,
besides invoking Basic.__new__.

Thus, my conclusion was that one should use __new__ if one needs to
have args properly initialised.

Sergiu

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to