A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2013-April/125615.html below:

[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard librarySerhiy Storchaka storchaka at gmail.com
Fri Apr 26 23:11:11 CEST 2013
26.04.13 05:13, Nick Coghlan написав(ла):
> With a merged design, it becomes *really* hard to give the instances
> custom behaviour, because the metaclass will somehow have to
> differentiate between namespace entries that are intended to be
> callables, and those which are intended to be instances of the enum.
> This is not an easy problem to solve.

What if use mixins? Shouldn't it work without magic?

class ColorMethods:

   def wave(self, n=1):
     for _ in range(n):
       print('Waving', self)

class Color(ColorMethods, Enum):

   red = 1
   white = 2
   blue = 3
   orange = 4


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4