In Python 3.3, support auto-numbering of items

Bug #1110507 reported by Barry Warsaw
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
flufl.enum
Won't Fix
Wishlist
Unassigned

Bug Description

Since Python 3.3 supports knowing the order of item definitions in the class, we could support auto numbering of items. We still need a syntax to indicate that autonumbering is requested. Possibly:

class Colors(Enum):
   red = None
   blue = None
   green = None

?

Revision history for this message
Barry Warsaw (barry) wrote :

Or possibly

from flufl.enum import Enum, auto

class Colors(Enum):
   red = auto
   blue = auto
   green = auto

?

Changed in flufl.enum:
importance: Undecided → Wishlist
Barry Warsaw (barry)
Changed in flufl.enum:
milestone: none → 3.4
Revision history for this message
Barry Warsaw (barry) wrote :

From mfoord:

With a Python 3 metaclass that provides default values for *looked up*
entries you could have this:

class Color(Enum):
    RED, WHITE, BLUE

Revision history for this message
Barry Warsaw (barry) wrote :

On python-ideas, Georg Brandl also suggested using ellipses, e.g.

class Colors(Enum):
    red = 1
   green = ...
   blue = ...

(From LP: #1124357)

Changed in flufl.enum:
status: New → Triaged
milestone: 3.4 → none
Revision history for this message
Barry Warsaw (barry) wrote :

I'm undecided about this wishlist item, and PEP 435 doesn't support it, so I'm disinclined to add it. Un-milestoning for 3.4.

Revision history for this message
Barry Warsaw (barry) wrote :

After further consideration and in consultation with Eli, marking this as Won't Fix since autonumbering really doesn't buy you enough for the added complexity.

Changed in flufl.enum:
status: Triaged → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.