[Python-checkins] peps: - The functional API gets a keyword-only `module` argument.

barry.warsaw python-checkins at python.org
Fri May 10 00:39:54 CEST 2013


http://hg.python.org/peps/rev/575129af919e
changeset:   4879:575129af919e
user:        Barry Warsaw <barry at python.org>
date:        Thu May 09 18:39:44 2013 -0400
summary:
  - The functional API gets a keyword-only `module` argument.
- Spell it 'mix-in'
- Clarify "behavior only"

files:
  pep-0435.txt |  17 +++++++++--------
  1 files changed, 9 insertions(+), 8 deletions(-)


diff --git a/pep-0435.txt b/pep-0435.txt
--- a/pep-0435.txt
+++ b/pep-0435.txt
@@ -410,11 +410,12 @@
 
 Some rules:
 
-1. When subclassing Enum, mixing types must appear before Enum itself in the
-   sequence of bases.
+1. When subclassing Enum, mix-in types must appear before Enum itself in the
+   sequence of bases, as in the ``IntEnum`` example above.
 2. While Enum can have members of any type, once you mix in an additional
    type, all the members must have values of that type, e.g. ``int`` above.
-   This restriction does not apply to behavior-only mixins.
+   This restriction does not apply to mix-ins which only add methods
+   and don't specify another data type such as ``int`` or ``str``.
 
 
 Functional API
@@ -432,12 +433,12 @@
     >>> list(Animal)
     [<Animal.ant: 1>, <Animal.bee: 2>, <Animal.cat: 3>, <Animal.dog: 4>]
 
-The semantics of this API resemble ``namedtuple``. The first argument of
-the call to ``Enum`` is the name of the enumeration.  This argument
-can be the short name of the enum or a dotted-name including the
-module path to better support pickling.  E.g.::
+The semantics of this API resemble ``namedtuple``. The first argument
+of the call to ``Enum`` is the name of the enumeration.  To support
+pickling of these enums, the module name can be specified using the
+``module`` keyword-only argument.  E.g.::
 
-    >>> Animals = Enum('animals.Animals', 'ant bee cat dog')
+    >>> Animals = Enum('Animals', 'ant bee cat dog', module=__name__)
 
 The second argument is the *source* of enumeration member names.  It can be a
 whitespace-separated string of names, a sequence of names, a sequence of

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list