Skip to content

Commit

Permalink
Done with tags-categories docs.
Browse files Browse the repository at this point in the history
Was going to include fuzzy matching functionality here, but it's more
useful when working with many Treants in a Bundle, so we'll cover it
there.
  • Loading branch information
dotsdl committed Mar 21, 2016
1 parent 49ec2cc commit 47bf070
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions docs/tags-categories.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,39 @@ Or checked for membership ::
>>> 'mirky' in s.tags
True

Tags function as sets
---------------------
Since the tags of a Treant behave as a set, we can do set operations directly,
such as subset comparisons::

>>> {'elm', 'misty'} < s.tags
True

Or unions::
unions::

>>> {'elm', 'misty'} | s.tags
>>> {'moldy', 'misty'} | s.tags
{'elm', 'mirky', 'misty', 'moldy'}

intersections::

>>> {'elm', 'moldy'} & s.tags
{'elm'}

differences::

>>> s.tags - {'moldy', 'misty'}
{'elm', 'mirky'}

or symmetric differences::

>>> s.tags ^ {'moldy', 'misty'}
{u'elm', u'mirky', 'moldy'}

It is also possible to set the tags directly::

>>> s.tags = s.tags | {'moldy', 'misty'}
>>> s.tags
<Tags(['elm', 'mirky', 'misty', 'moldy'])>

API Reference: Tags
-------------------
Expand Down

0 comments on commit 47bf070

Please sign in to comment.