Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:object': 0.07; 'subject:None': 0.09; 'am,': 0.12; 'classes,': 0.13; 'received:209.85.210.174': 0.13; 'received:mail- iy0-f174.google.com': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'shed': 0.16; 'mon,': 0.16; 'wrote:': 0.18; '>>>': 0.18; '(most': 0.21; 'subject:not': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; '(on': 0.23; 'though.': 0.23; 'traceback': 0.24; 'classes': 0.26; 'windows': 0.26; 'testing': 0.26; 'message-id:@mail.gmail.com': 0.28; 'pass': 0.29; 'class': 0.29; 'subject:Test': 0.30; 'typeerror:': 0.30; 'certainly': 0.32; "can't": 0.32; 'actually': 0.33; 'there': 0.33; 'done': 0.34; 'to:addr:python-list': 0.34; 'certain': 0.34; 'last):': 0.34; 'file': 0.36; 'shows': 0.37; 'acceptable': 0.37; 'thread': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'think': 0.37; 'steven': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'type': 0.61; '2011': 0.61; 'types': 0.61; '26,': 0.67; '12:48': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=uFjJe9+UHp75eMbC2FXS9n+b+q946HzgswOvJ8j/xj0=; b=qqD17HKfV4LBK7TbaQPdSxAjyRg88xYkeBMhvugSik4UPtHcz48StQC5gv4FBzStLI 7CAooZWMF1xaE6eQI+EzRz3rKRts2GKbRal8VmZnT+fBNqGH5MB5EB1XUoQgzstKaN0H g8wpUgbZmQQoufyVEE5SjcHH9J7aRq7nQkJK8= MIME-Version: 1.0 In-Reply-To: <4ef729aa$0$29973$c3e8da3$5496439d@news.astraweb.com> References: <0d80ce25-9e65-4216-b26c-b8ee40f989a3@q9g2000yqe.googlegroups.com> <4ef729aa$0$29973$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 26 Dec 2011 01:04:06 +1100 Subject: Re: Test None for an object that does not implement == From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324821849 news.xs4all.nl 6879 [2001:888:2000:d::a6]:34072 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17902 On Mon, Dec 26, 2011 at 12:48 AM, Steven D'Aprano wrote: > I can't think of any other un-subclassable classes other than NoneType. > Which ones are you thinking of? I don't remember, but it was mentioned in a thread a little while ago. Experimentation shows that 'bool' is one of them, though. This may shed some light: >>> class Foo(type(iter)): pass Traceback (most recent call last): File "", line 1, in class Foo(type(iter)): TypeError: type 'builtin_function_or_method' is not an acceptable base type I think there are certain types that are actually not implemented as classes, and hence cannot be subclassed. This is almost certainly an implementation detail though; my testing was done in Py3.2 (on Windows fwiw). ChrisA