Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'method,': 0.07; 'prints': 0.07; '(it': 0.09; '*is*': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'overridden': 0.09; 'received:gator410.hostgator.com': 0.09; 'subclass': 0.09; '~ethan~': 0.09; 'pm,': 0.11; 'this:': 0.11; 'wrote:': 0.14; 'furman': 0.16; 'okay,': 0.16; 'precede': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'roy': 0.16; 'used...': 0.16; 'user-defined': 0.16; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; '(which': 0.21; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'etc,': 0.23; "list's": 0.23; 'says': 0.25; 'compare': 0.26; 'subject:?': 0.29; 'class': 0.29; 'elements': 0.29; 'list': 0.30; 'cc:addr:python.org': 0.31; 'equal': 0.31; 'etc)': 0.33; 'print': 0.35; 'header:User-Agent:1': 0.35; 'list.': 0.35; 'think': 0.36; 'should': 0.37; 'header:Received:5': 0.40; 'fact,': 0.60; 'received:hostgator.com': 0.64; 'received:websitewelcome.com': 0.71; 'order,': 0.73; 'received:69.56': 0.77 Date: Thu, 12 May 2011 14:48:20 -0700 From: Ethan Furman User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: Roy Smith Subject: Re: list equal to subclass of list? References: <55506367-5E1C-440B-A2D4-73159339D2E6@panix.com> <925edfdd-51c7-400b-af2b-4171779779c8@r35g2000prj.googlegroups.com> In-Reply-To: <925edfdd-51c7-400b-af2b-4171779779c8@r35g2000prj.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:3818 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1305236181 news.xs4all.nl 81479 [::ffff:82.94.164.166]:35479 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:5268 Roy Smith wrote: > On May 12, 2:29 pm, Ethan Furman wrote: > >> While it is wrong (it should have 'built-in' precede the word 'types'), >> it is not wrong in the way you think -- a subclass *is* a type of its >> superclass. > > Well, consider this: > > class List_A(list): > "A list subclass" > > class List_B(list): > "Another list subclass" > > a = List_A() > b = List_B() > print a == b > > It prints "True". Neither a nor b are a type of the other: > > print isinstance(List_A, List_B) > print isinstance(List_B, List_A) > > False > False Okay, considering: List_A is a user-defined type. List_B is a user-defined type. Both are sub-classes of list. Corrected documentation (which says 'built-in types' etc, etc) says nothing about user-defined types not being able to be equal to each other neither List_A nor List_B have overridden the __eq__ method, so list.__eq__ will be used... conclusion: if they have equal elements in the same order, they will compare equal since they are, in fact, list's Do you not get the same conclusion? ~Ethan~