def make_label_dec(label,ds=None):
if isinstance(label,basestring):<EOL><INDENT>labels = [label]<EOL><DEDENT>else:<EOL><INDENT>labels = label<EOL><DEDENT>tmp = lambda : None<EOL>for label in labels:<EOL><INDENT>setattr(tmp,label,True)<EOL><DEDENT>def decor(f):<EOL><INDENT>for label in labels:<EOL><INDENT>setattr(f,label,True)<EOL><DEDENT>return f<EOL><DEDENT>if ds is None:<EOL><INDENT>ds = "<STR_LIT>" % label<EOL><DEDENT>decor.__doc__ = ds<EOL>return decor<EOL>
Factory function to create a decorator that applies one or more labels.

    Parameters
    ----------
      label : string or sequence
      One or more labels that will be applied by the decorator to the functions
    it decorates.  Labels are attributes of the decorated function with their
    value set to True.

      ds : string
      An optional docstring for the resulting decorator.  If not given, a
      default docstring is auto-generated.

    Returns
    -------
      A decorator.

    Examples
    --------

    A simple labeling decorator:
    >>> slow = make_label_dec('slow')
    >>> print slow.__doc__
    Labels a test as 'slow'.

    And one that uses multiple labels and a custom docstring:
    >>> rare = make_label_dec(['slow','hard'],
    ... "Mix labels 'slow' and 'hard' for rare tests.")
    >>> print rare.__doc__
    Mix labels 'slow' and 'hard' for rare tests.

    Now, let's test using this one:
    >>> @rare
    ... def f(): pass
    ...
    >>>
    >>> f.slow
    True
    >>> f.hard
    True