~openerp-dev/openobject-server/trunk-missing-default-values-pza

« back to all changes in this revision

Viewing changes to openerp/tools/func.py

  • Committer: Antony Lesuisse
  • Date: 2014-01-31 00:52:07 UTC
  • mfrom: (4854.4.369 trunk-website-al)
  • mto: This revision was merged to the branch mainline in revision 5025.
  • Revision ID: al@openerp.com-20140131005207-mn7t6tar8cywe9hz
[MERGE] trunk-website-al

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    except Exception:
58
58
        return "<unknown>", ''
59
59
 
 
60
def compose(a, b):
 
61
    """ Composes the callables ``a`` and ``b``. ``compose(a, b)(*args)`` is
 
62
    equivalent to ``a(b(*args))``.
 
63
 
 
64
    Can be used as a decorator by partially applying ``a``::
 
65
 
 
66
         @partial(compose, a)
 
67
         def b():
 
68
            ...
 
69
    """
 
70
    @wraps(b)
 
71
    def wrapper(*args, **kwargs):
 
72
        return a(b(*args, **kwargs))
 
73
    return wrapper
 
74
 
60
75
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: