On 04/26/2013 08:50 AM, Larry Hastings wrote:
FWIW I'm +0.5 on "the enum metaclass ignores callables and
descriptors".  This seems reasonably Pythonic, much more so than "ignore
everything except ints and strings".  And as long as we're
special-casing it I think we should opt for flexibility. Certainly I see
nothing wrong with enums of float, complex, Decimal, and Fraction, so I
don't see a good place to draw the line with a whitelist.

A whitelist, if we go that route, should be on a per Enum basis -- so something like:

  class Planets(str, Enum):
      PLUTO = 'it is too a planet!'
      MERCURY = 'definitely a planet'
      SATURN = 'darn big planet'

      solar_mass = 82738273  # or some  really big number
      light_year = 1827499   # another really big number (of feet!)

      def horrorscope(self, message):
          return ('%s will be in retrograde... '
             'don't communicate today.' % self)


and only PLUTO, MERCURY, and SATURN would be converted to enums.

--
~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to