Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions cycler.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
"""
Cycler
======

Cycling through combinations of values, producing dictionaries.

You can add cyclers::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need a blank line between these sections for the parsing to work right.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

from cycler import cycler
cc = (cycler('color', list('rgb')) +
cycler('linestyle', ['-', '--', '-.']))
for d in cc:
print(d)

Results in::
{'color': 'r', 'linestyle': '-'}
{'color': 'g', 'linestyle': '--'}
{'color': 'b', 'linestyle': '-.'}

You can multiply cyclers::
from cycler import cycler
cc = (cycler('color', list('rgb')) *
cycler('linestyle', ['-', '--', '-.']))
for d in cc:
print(d)

Results in::
{'color': 'r', 'linestyle': '-'}
{'color': 'r', 'linestyle': '--'}
{'color': 'r', 'linestyle': '-.'}
{'color': 'g', 'linestyle': '-'}
{'color': 'g', 'linestyle': '--'}
{'color': 'g', 'linestyle': '-.'}
{'color': 'b', 'linestyle': '-'}
{'color': 'b', 'linestyle': '--'}
{'color': 'b', 'linestyle': '-.'}
"""

from __future__ import (absolute_import, division, print_function,
unicode_literals)

Expand Down