This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from unittest import TestCase | |
| def walk_data(root): | |
| """Walk a nested data structure like os.walk""" | |
| data = root[-1] | |
| root = root[:-1] | |
| if hasattr(data, 'items'): | |
| for key, value in data.items(): | |
| yield root + (key,), value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| import types | |
| def collect(collection_type): | |
| """A decorator that will collect stuff from a generator. For example, | |
| >>> def tuple_generator(): | |
| ... yield ('a', 'b') | |
| ... yield ('c', 'd') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| from datetime import timedelta, date | |
| from collections.abc import Sequence, Iterator | |
| from itertools import islice | |
| class date_range(Sequence): | |
| def __init__(self, start, stop, step=timedelta(days=1)): | |
| self.start = start |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer