Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!81.171.88.16.MISMATCH!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone04.am1.xlned.com!bcyclone04.am1.xlned.com!newsfeed.xs4all.nl!newsfeed3.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'anyway.': 0.05; 'cc:addr :python-list': 0.11; 'def': 0.12; 'jan': 0.12; '24,': 0.16; 'expecting': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'figure': 0.32; 'skip:_ 10': 0.34; 'received:google.com': 0.35; "didn't": 0.36; 'pm,': 0.38; 'hear': 0.63; '2015': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=KygYBwfI2MERuCL5ipzVUOFFEDY6rEP2qwwJfzZSpvA=; b=iwgHqetgKjdM8fuK74rEB78kF4Mc/S2RLVG6qmZtASs8tUvS6JH44eMyLIY+HQRjnS 2wpyJMMj7d0Yq5yMGbB2A2XYkwGfBWqTpzViLkca/NPElT+TyLUEqFENbTcKGYB9OfD5 wsi7f0sf8wMNuJlkO7UZ0HQ8A0OaYqNbK/MS7O5hL7W+GyNygaqjNfeD+RonyDWfS1yV fjQrELiPFA1jm8A2ZLDYCfGj2cEotWv4fkHDFcDwP5wFDFCOWTych1QnUQo5xAsdQA3J ka+jnxpI3Jlwsaxhidiabxiu8TvVAOI9vvo3QDSBOFYxW/m3XN7QMuXtC8zmsBq9QnL9 eYYQ== MIME-Version: 1.0 X-Received: by 10.224.128.196 with SMTP id l4mr21944174qas.100.1422078213010; Fri, 23 Jan 2015 21:43:33 -0800 (PST) In-Reply-To: <54c32716$0$13009$c3e8da3$5496439d@news.astraweb.com> References: <54ABB88A.7070504@r3dsolutions.com> <54AC97D9.4010504@r3dsolutions.com> <54ACAA04.60801@r3dsolutions.com> <54ADC99F.3020405@stoneleaf.us> <54B44A64.7010105@r3dsolutions.com> <54b4aded$0$2738$c3e8da3$76491128@news.astraweb.com> <54B5B486.7080406@r3dsolutions.com> <54B72D32.3090209@r3dsolutions.com> <54B76B0A.7050706@r3dsolutions.com> <5a785a32-3855-457f-be3f-76066dfb20c8@googlegroups.com> <54c32716$0$13009$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 24 Jan 2015 16:43:32 +1100 Subject: Re: Comparisons and sorting of a numeric class.... From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422078215 news.xs4all.nl 2852 [2001:888:2000:d::a6]:34028 X-Complaints-To: abuse@xs4all.nl X-Received-Body-CRC: 2385388660 X-Received-Bytes: 4722 Xref: csiph.com comp.lang.python:84438 On Sat, Jan 24, 2015 at 4:01 PM, Steven D'Aprano wrote: > # Untested > class B4(IntEnum): > F1 = 0 > F2 = 1 > F3 = 2 > T = 3 > def __bool__(self): > return self is B4.T > def __str__(self): > if self is B4.F1: return "Certainly False" > if self is B4.F2: return "Maybe False" > if self is B4.F3: return "Maybe True" > if self is B4.T: return "Certainly True" I keep expecting to hear Bluebottle asking about why we didn't figure this out B4... anyway. class B4(IntEnum): CertainlyFalse = 0 MaybeFalse = 1 MaybeTrue = 2 CertainlyTrue = 3 def __bool__(self): return self is B4.CertainlyTrue Now you don't need a __str__ function. :) ChrisA