Path: csiph.com!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: Differences creating tuples and collections.namedtuples Date: Tue, 19 Feb 2013 20:54:49 +1300 Lines: 28 Message-ID: References: <7a40a426-baa9-46f8-8f9d-59ba32b044f3@googlegroups.com> <5122c4d7$0$29982$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net +Gco34nzj/o8HaIQdYu2GAt4vY2OGIYDFB1OH/+JQwmRFKWDxlUmD+4O7VdFDVtsGf Cancel-Lock: sha1:vmhPiM1gC2cHfZVoZD3aIz67hdA= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: <5122c4d7$0$29982$c3e8da3$5496439d@news.astraweb.com> Xref: csiph.com comp.lang.python:39189 Steven D'Aprano wrote: > Terry Reedy wrote: >>In fact, one reason to subclass a class is to change the initialization >>api. > That might be a reason that people give, but it's a bad reason from the > perspective of interface contracts, duck-typing and the LSP. Only if you're going to pass the class off to something as a factory function. Note that having a different constructor signature is *not* an LSP violation for *instances* of a class. The constructor is not part of the interface for instances, only for the class itself. In practice, it's very common for a class to have a different constructor signature from its base class, and this rarely causes any problem. IPython is simply making a dodgy assumption. It gets away with it only because it's very rare to encounter subclasses of list or tuple at all. -- Greg