{"body": "
\n

# Quickstart Guide\u00b6

\n

Collectors was originally developed to monitor SimPy processes, but it\ncan be used to monitor any types of objects or variables. Thus, these first,\nsimple examples demonstrate the usage of Collectors with ordinary Python\nobjects; SimPy is dedicated an own section.

\n
\n

## Monitor an object\u2019s attributes\u00b6

\n

Simply monitoring an objects values is really easy:

\n

    >>> from collectors import Collector, get\n>>> class Spam(object):\n...     a = 1\n...     b = 2\n...\n>>> spam = Spam()\n>>> col = Collector(get(spam, 'a', 'b'))\n>>> col()\n>>> spam.a, spam.b = 3, 4\n>>> col()\n>>> col\n([1, 3], [2, 4])\n>>> col.a\n[1, 3]\n>>> col.b == col[1]\nTrue\n

\n
\n

When you create a new `Collector` instance, you need to\ntell it which objects and which attributes to monitor. This can e.g. be done by\nusing the shortcut function `get()`.

\n

To save the current state of the the monitored objects, just make a call to the\ncollector instance (if you don\u2019t like this, there is also a\n`collect()` method that does the same).

\n

`Collector` inherits `tuple` and stores each\nseries for the monitored objects as an entry. It also creates an object\nattribute for each series based on its name, so you can access each series\neither by name or by index and handle the collector itself as a simple tuple.

\n
\n
\n

## Iterating over a collector\u00b6

\n

Since a collector is basically just a tuple, you can easily iterate over its\nseries as well as of the the values of all series. If you imagine your collector\nas a table with a column for each monitored attribute, the first loop iterates\nover each column while the second one iterates over each row:

\n

    >>> for series in col:\n...     print series\n[1, 3]\n[2, 4]\n>>> for a, b in zip(*col):\n...     print 'a: %d | b: %d' % (a, b)\na: 1 | b: 2\na: 3 | b: 4\n

\n
\n
\n
\n

## What\u2019s next?\u00b6

\n

You now know how to use Collectors for simple tasks. The next section will\ndescribe in detail, how `Collector` works and which\nshortcuts we have to make defining a collector easier.

\n
\n
\n", "display_toc": true, "title": "Quickstart Guide", "sourcename": "quickstart.txt", "current_page_name": "quickstart", "next": {"link": "../collector/", "title": "The Collector in-depth"}, "rellinks": [["genindex", "General Index", "I", "index"], ["modindex", "Global Module Index", "M", "modules"], ["collector", "The Collector in-depth", "N", "next"], ["index", "Welcome to Collectors\u2019 documentation!", "P", "previous"]], "meta": {}, "parents": [], "toc": "

\n
- Quickstart Guide
  \n
  - Monitor an object\u2019s attributes
  \n
  - Iterating over a collector
  \n
  - What\u2019s next?
  \n
  \n
\n

\n", "prev": {"link": "../", "title": "Welcome to Collectors\u2019 documentation!"}, "metatags": ""}