Michele Simionato wrote:
It would be good to have a clear exposition of the pros and cons of
__new__ usage.


It is there mostly because __init__ would not work on immutable types.
OTOH, you probably do not want to use __new__ on mutable types
(once I was caught by this trap, google for "overriding list.__new__"
if you are interested).
Michele Simionato


Thanks.  The use of __new__ for immutable classes is described in:
         http://www.python.org/2.2.3/descrintro.html

This distinction hadn't registered with me before.

The Martelli bible doesn't bring this out.

It seems to me that __new__ should probably be deprecated for mutable classes.

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

Reply via email to