On Thu, Apr 23, 2009 at 9:48 AM, Ondrej Certik <ond...@certik.cz> wrote:
> On Tue, Apr 21, 2009 at 8:46 AM, dhruv <lasnabvu...@gmail.com> wrote:
>> It seems like the above is the only thing I can do!  The Poly class
>> can be instantiated using a few different calling schemes (lists,
>> tuples, dictionaries, &c.) and I'm going to have to anticipate each
>> scheme and extract the parameters I want from it, all in
>> GeneratingFunction.__new__.
>
> It depends what functionality you want to support --- if you want your
> class to work with all those schemes *and* you need to do something
> with the arguments, then I think it's the only way. However, we can
> refactor Poly, so that these kind of things are easy to do.


Btw, the reason to use __new__ instead of __init__ is that in __init__
you cannot decide which instance to return (e.g. the instance has
already been created). For simplifications like

x+x

we need to return Mul(2, x). This is decided in the __new__ method, so
that no unnecessary instances are created.

Ondrej

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

Reply via email to