Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Michael Selik Newsgroups: comp.lang.python Subject: Re: Enum questions. Date: Wed, 13 Apr 2016 12:08:42 +0000 Lines: 28 Message-ID: References: <570E1B98.4080904@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de Jy/rP3qXOTA0QxoAyHMbKgeh0lZY4iU/0kxMFfrXL/fQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'value,': 0.03; 'corresponds': 0.09; 'enum': 0.09; 'iterate': 0.09; 'received:74.125.82.44': 0.15; 'wed,': 0.15; '(but': 0.15; 'missing?': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'comparing': 0.18; 'to:2**1': 0.21; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'values': 0.28; '13,': 0.29; 'coded': 0.29; 'comparison': 0.29; 'url:python': 0.33; 'received:google.com': 0.35; 'important.': 0.35; 'received:74.125.82': 0.35; 'should': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'two': 0.37; 'skip:& 10': 0.37; 'missing': 0.37; 'data': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'skip:n 10': 0.62; 'between': 0.65; 'miss': 0.77; 'nominal': 0.84; 'pardon': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Mh0jhhNlovjjKr3Caitpa+iuyzoInmarlQyD3tzMzdw=; b=d4vLHt9JcC7pwRIXvTKHYt57VX4/+insBijjUwCA5RT3iW0Eh5Lq8EaNFo5nw30SGQ iwtsMJDqF5e/kQ8Zcm5CIVyl4ikxTqNmLjk1NdaIVaYJKxSu1nMKlebCQ6QCXc98ewko +m6/ME1OWQS9xVPfL47KwiUkosQJoG3uZxX/wa0ym94uENt+znVxSMjEzcyKdZk/1GZ/ tUocuxkopVv2R6hAIXsAa/W2xd6dd6HT3ic5oOnE94dfuW0ZbgqvDadt50h6Pw/Z6w0B LdbC173wetYFETmxqciXh83E95Zx+1kQRX1wtLIt6dvRFfUjfLBez66oCiem/3G7Da3n MF2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Mh0jhhNlovjjKr3Caitpa+iuyzoInmarlQyD3tzMzdw=; b=jIUqkNSFXsuhZa+MicTTDn5Q98lX0VW34hvUD2EehLCykonHBT++TnGSO6oGuRYaKx 0vn1nN6s6c0TqNe1aMscZT9L+OR1orxcyRFxotECnorMH0RwanD2BY88jh7lqkXHQ0NW we0A5uA2Y8Hz7pbDAjSatPPNlqXV6RvPfEygZ8N+I4fbVsUP5qVzS3HBEOdq6x0xAXXy 9Tii5+NL516QtPlPYa9Fxdvq4OTtBiYnkcyd2t0itcr9bvnAtWYKOQhzZvz4RLchQZ/k BD1/Qied0mpT8MbykFWr3JXXSsIOdoHgYn8S6Z2zAJRpG3hvktgBXPmoDG+FW6aW0/eD C5jg== X-Gm-Message-State: AOPr4FUqSZwWeuntGkIM+jO9D8j0G5vHBjeJ6effRRZtKBIBWZNsLR8varNon6G6q/jA9GbXtYAWiV1/oyqYXQ== X-Received: by 10.194.184.38 with SMTP id er6mr9073876wjc.93.1460549331729; Wed, 13 Apr 2016 05:08:51 -0700 (PDT) In-Reply-To: <570E1B98.4080904@rece.vub.ac.be> X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <570E1B98.4080904@rece.vub.ac.be> Xref: csiph.com comp.lang.python:106937 On Wed, Apr 13, 2016, 12:14 PM Antoon Pardon wrote: > I have been looking at the enum documentation and it > seems enums are missing two features I rather find > important. > > 1) Given an Enum value, someway to get the next/previous > one > > 2) Given two Enum values, iterate over the values between > them. > > Did I miss those in the documentation or are they really > missing? > An Enum corresponds to "nominal" data that is coded as a number simply for storage rather than meaning. If you want next/previous you are thinking of "ordinal" data which is coded as numbers for the purpose of comparison (but not arithmetic). Placing nominal data in order would be comparing apples and oranges, so to speak. However, IntEnum should give you the features you want. https://docs.python.org/3/library/enum.html#intenum >