[Python-Dev] enum discussion: can someone please summarize open issues? (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Sat May 4 13:33:39 CEST 2013
- Previous message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Next message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, 4 May 2013 16:42:08 +1000 Nick Coghlan <ncoghlan at gmail.com> wrote:
On Sat, May 4, 2013 at 4:10 PM, Georg Brandl <g.brandl at gmx.net> wrote: > Am 04.05.2013 01:22, schrieb Antoine Pitrou: >> On Sat, 04 May 2013 11:15:17 +1200 >> Greg Ewing <greg.ewing at canterbury.ac.nz> wrote: >>> Eli Bendersky wrote: >>> > I'm just curious what it is about enums that sets everyone on a "let's >>> > make things safer" path. Python is about duck typing, it's absolutely >>> > "unsafe" in the static typing sense, in the most fundamental ways >>> > imaginable. >>> >>> This isn't about catching bugs in the program, it's >>> about validating user input. That's a common enough >>> task that it deserves to have a convenient way to >>> do it correctly. >> >> +1. An enum is basically a bidirectional mapping between some raw >> values and some "nice" instances, so it deserves a well-defined lookup >> operation in each direction.
As I see it, there are 3 possible ways forward here:
- Offer classmethods named Enum.by_name() and Enum.by_value(). Simple and explicit.
Regards
Antoine.
- Previous message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Next message: [Python-Dev] enum discussion: can someone please summarize open issues?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]