diff options
| author | micheles <micheles@micheles-mac> | 2010-05-22 09:08:40 +0200 |
|---|---|---|
| committer | micheles <micheles@micheles-mac> | 2010-05-22 09:08:40 +0200 |
| commit | 3346499362d111158ae051a2bb17504f01344d58 (patch) | |
| tree | 1de31cfbde75976252ed6df924ec6beeae7f4e81 /documentation.py | |
| parent | 4452ad10bcf032717f561bc825538e6daecd4c8a (diff) | |
| download | python-decorator-git-3346499362d111158ae051a2bb17504f01344d58.tar.gz | |
Version 3.2 of the decorator module
Diffstat (limited to 'documentation.py')
| -rw-r--r-- | documentation.py | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/documentation.py b/documentation.py index cdd4fae..aff5d17 100644 --- a/documentation.py +++ b/documentation.py @@ -384,18 +384,20 @@ be locked. Here is a minimalistic example: Each call to ``write`` will create a new writer thread, but there will be no synchronization problems since ``write`` is locked. ->>> write("data1") # doctest: +ELLIPSIS -<Thread(write-1, started...)> - ->>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1 - ->>> write("data2") # doctest: +ELLIPSIS -<Thread(write-2, started...)> - ->>> time.sleep(2) # wait for the writers to complete +.. code-block:: python ->>> print datalist -['data1', 'data2'] + >>> write("data1") # doctest: +ELLIPSIS + <Thread(write-1, started...)> + + >>> time.sleep(.1) # wait a bit, so we are sure data2 is written after data1 + + >>> write("data2") # doctest: +ELLIPSIS + <Thread(write-2, started...)> + + >>> time.sleep(2) # wait for the writers to complete + + >>> print datalist + ['data1', 'data2'] The ``FunctionMaker`` class --------------------------------------------------------------- @@ -729,23 +731,32 @@ a *copy* of the original function dictionary Compatibility notes --------------------------------------------------------------- -Version 3.0 is a complete rewrite of the original implementation. -It is mostly compatible with the past, a part for a few differences. - -First of all, the utilites ``get_info`` and ``new_wrapper``, available -in the 2.X versions, have been deprecated and they will be removed -in the future. For the moment, using them raises a ``DeprecationWarning``. -Incidentally, the functionality has been implemented through a -decorator which makes a good example for this documentation: - -$$deprecated - -``get_info`` has been removed since it was little used and since it had -to be changed anyway to work with Python 3.0; ``new_wrapper`` has been -removed since it was useless: its major use case (converting -signature changing decorators to signature preserving decorators) -has been subsumed by ``decorator_apply`` -and the other use case can be managed with the ``FunctionMaker``. +Version 3.2 is the first version of the ``decorator`` module to officially +support Python 3.0. Actually, the module has supported Python 3.0 from +the beginning, via the ``2to3`` conversion tool, but this step has +been now integrated in the build process, thanks to the distribute_ +project, the Python 3-compatible replacement of easy_install. +The hard work (for me) has been converting the documentation and the +doctests. This has been possibly only now that docutils_ and pygments_ +have been ported to Python 3. + +The ``decorator`` module *per se* does not contain any change, apart +from the removal of the functions ``get_info`` and ``new_wrapper``, +which have been deprecated for years. ``get_info`` has been removed +since it was little used and since it had to be changed anyway to work +with Python 3.0; ``new_wrapper`` has been removed since it was +useless: its major use case (converting signature changing decorators +to signature preserving decorators) has been subsumed by +``decorator_apply`` and the other use case can be managed with the +``FunctionMaker``. + +There are a few changes in the documentation: I removed the +``decorator_factory`` example, which was confusing some of my users, +and I removed the part about exotic signatures in the Python 3 +documentation, since Python 3 does not support them. +Notice that there is no support for Python 3 `function annotations`_ +since it seems premature at the moment, when most people are +still using Python 2.X. Finally ``decorator`` cannot be used as a class decorator and the `functionality introduced in version 2.3`_ has been removed. That @@ -755,25 +766,21 @@ All these changes should not cause any trouble, since they were all rarely used features. Should you have any trouble, you can always downgrade to the 2.3 version. -The examples shown here have been tested with Python 2.5. Python 2.4 +The examples shown here have been tested with Python 2.6. Python 2.4 is also supported - of course the examples requiring the ``with`` -statement will not work there. Python 2.6 works fine, but if you +statement will not work there. Python 2.5 works fine, but if you run the examples here in the interactive interpreter you will notice a few differences since ``getargspec`` returns an ``ArgSpec`` namedtuple instead of a regular tuple. That means that running the file ``documentation.py`` under Python 2.5 will a few errors, but -they are not serious. Python 3.0 is kind of supported too. -Simply run the script ``2to3`` on the module -``decorator.py`` and you will get a version of the code running -with Python 3.0 (at least, I did some simple checks and it seemed -to work). However there is no support for `function annotations`_ yet -since it seems premature at this moment (most people are -still using Python 2.5). +they are not serious. .. _functionality introduced in version 2.3: http://www.phyast.pitt.edu/~micheles/python/documentation.html#class-decorators-and-decorator-factories .. _function annotations: http://www.python.org/dev/peps/pep-3107/ - +.. _distribute: http://packages.python.org/distribute/ +.. _docutils: http://docutils.sourceforge.net/ +.. _pygments: http://pygments.org/ LICENCE --------------------------------------------- |
