Jonathan Eunice  committed 0caa8e0

added with_metaclass function; bumped to 0.5 and production/stable

  • Participants
  • Parent commits 7070fc3
  • Branches default

Comments (0)

Files changed (3)

 Unfortunately, Python 2 and Python 3 don't recognize each other's syntax for
 metaclass specification, so straightforward code for one won't even compile for
-the other. You can get around this by using the ``with_metaclass()`` function
-from the ``six`` cross-version compatibility module. It's very short, so you can
-drop it into any program::
+the other. You can get around this by using the ``with_metaclass()`` function,
+which is similar to that found in the ``six`` cross-version compatibility
-    def with_metaclass(meta, base=object):
-        """Create a base class with a metaclass."""
-        return meta("NewBase", (base,), {})
+    from mementos import MementoMetaclass, with_metaclass
     class Thing23(with_metaclass(MementoMetaclass, object)):
-alternatively you can import it from the ``six`` module.
-You could even inline what ``with_metaclass()`` does directly, but it's
-really ugly, hard-to-read, and not recommended.
 Careful with Call Signatures
     in a multi-threaded environment, consider wrapping object instantiation
     in a lock.
- *  Automated multi-version testing with 
+ *  Automated multi-version testing managed with 
     `pytest <>`_
-    and `tox <>`_ modules has commenced. ``mementos`` is now
-    successfully packaged for, and tested against, all late-model verions of
+    and `tox <>`_. Successfully packaged for, and tested against, all late-model verions of
     Python (2.6, 2.7, 3.2, and 3.3), plus one (2.5) that isn't so very recent,
     and one (PyPy 1.9, based on Python 2.7.2) that is differently implemented.
                                    lambda cls, args, kwargs: (cls, ) + args + tuple(kwargs.items()) )
+def with_metaclass(meta, base=object):
+    """
+    Create a base class with a metaclass.
+    """
+    if not isinstance(base, tuple):
+        basetuple = (base,)
+    return meta("NewBase", basetuple, {})
 # Some reading:
-    version=verno("0.467"),
+    version=verno("0.501"),
     author='Jonathan Eunice',
     description='Memoizing metaclass. Drop-dead simple way to create cached objects',
     tests_require = ['tox', 'pytest'],
     zip_safe = True,
-        Development Status :: 4 - Beta
+        Development Status :: 5 - Production/Stable
         Operating System :: OS Independent
         License :: OSI Approved :: BSD License
         Intended Audience :: Developers