Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'literal': 0.09; 'valueerror:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; '24,': 0.16; '__new__': 0.16; 'declared': 0.16; 'enum': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hack,': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'work,': 0.20; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'skip:" 30': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '"",': 0.31; 'workaround': 0.31; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'example,': 0.37; 'recent': 0.39; 'does': 0.39; 'even': 0.60; 'future': 0.60; 'total': 0.65; 'invalid': 0.68; '10:': 0.84; '2015': 0.84; 'hardly': 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=2S9jOtV3USjhiv4AhCLQooNlMhm31d6qwoH/Cd9v7eg=; b=AIP/Mg0EDcfSDBNAt+sb5p3RkLIT5sy+8NaxrBSlGqaOjoJD7mAl9FY7lgd2X4MhS0 ZB3c7+CR9Yyk0qDHHnjM56ASmWTx4lFffIQuirkBTZnHepKnIrAp34aeSv2QZxtFMjlD yIre9HeEp6hOfk0BQSWr+M6LPvfZx2vYkY8xRFtNG9XgnPsZvoK6wJr+oeNi+N4kxyWn hPlymLBrbd7td7ufwMvlEcDitTWFlFHTfkQFW+9rjBW9f+3arbHQc+aAoKBo3QS2P9tL 42UnnUrFFj28/ZRpiu6pVLAbiqn59Z+RE2ynstOIvYY8kwY1Wjmper00NVhuLgHhjwzm KYJw== MIME-Version: 1.0 X-Received: by 10.224.23.133 with SMTP id r5mr16507042qab.88.1422033824860; Fri, 23 Jan 2015 09:23:44 -0800 (PST) In-Reply-To: <5a785a32-3855-457f-be3f-76066dfb20c8@googlegroups.com> References: <54ABB88A.7070504@r3dsolutions.com> <54ABC52A.1050507@davea.name> <54ABE383.3020801@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> Date: Sat, 24 Jan 2015 04:23:44 +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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422033834 news.xs4all.nl 2840 [2001:888:2000:d::a6]:38307 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84363 On Sat, Jan 24, 2015 at 4:03 AM, Rustom Mody wrote: > The only workaround I have been able to come up with is: > > class B4(IntEnum): >> F1 = 0 >> F2 = "" >> F3 = None >> T = 1 > > which is not bad; its ridiculous It's ridiculous because you declared an IntEnum and then started using non-integer values that boolify to the same value (and don't intify). If that even works, it's a total hack, and it might stop working in a future version... for example, it doesn't seem to work on my Python 3.5: >>> class B4(IntEnum): ... F1=0 ... F2="" ... F3=None ... T=1 ... Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.5/enum.py", line 152, in __new__ enum_member = __new__(enum_class, *args) ValueError: invalid literal for int() with base 10: '' Using Enum instead of IntEnum does work, but it's still hardly a normal use of an enumeration. ChrisA