diff --git a/README.md b/README.md index 5c5b17d..414b235 100644 --- a/README.md +++ b/README.md @@ -750,51 +750,61 @@ Itertools from itertools import * ``` -### Chain -```python ->>> chain([1, 2], range(3, 5)) -[1, 2, 3, 4] -``` +### Math -### Combinations +#### Combinations: ```python >>> combinations('abc', 2) [('a', 'b'), ('a', 'c'), ('b', 'c')] ``` -### Permutations +#### Combinations with Replacement: +```python +>>> ombinations_with_replacement('abc', 2) +[('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')] +``` + +#### Permutations: ```python >>> permutations('abc', 2) [('a', 'b'), ('a', 'c'), ('b', 'a'), ('b', 'c'), ('c', 'a'), ('c', 'b')] ``` -### Product +#### Product: ```python ->>> list(product('ab', [1, 2])) +>>> product('ab', [1, 2]) [('a', 1), ('a', 2), ('b', 1), ('b', 2)] ``` -### Compress +### Util + +#### Chain: +```python +>>> chain([1, 2], range(3, 5)) +[1, 2, 3, 4] +``` + +#### Compress: ```python >>> compress('abc', [True, 0, 23]) ['a', 'c'] ``` -### Count +### Count: ```python >>> i = count(5, 2) >>> next(i), next(i) (5, 7) ``` -### Cycle +#### Cycle: ```python >>> a = cycle('abc') >>> [next(a) for _ in range(10)] ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c', 'a'] ``` -### Groupby +#### Groupby: ```python >>> a = [{'id': 1, 'name': 'bob'}, {'id': 2, 'name': 'bob'}, @@ -805,7 +815,7 @@ from itertools import * 'peter': [{'id': 3, 'name': 'peter'}]} ``` -### Islice +#### Islice: ```python islice([1, 2, 3], 1, None) [2, 3] @@ -850,6 +860,14 @@ False >>> setattr(z, 'c', 10) ``` +### Parameters +```python +>>> from inspect import signature +>>> sig = signature(bla) +>>> len(sig.parameters) +3 +``` + ### Type **Type is the root class. If only passed the object it returns it's type. Otherwise it creates a new class (and not the instance!):** ```python @@ -861,6 +879,7 @@ type(class_name, parents, attributes) >>> z = Z() ``` + ### MetaClass #### Class that creates class: ```python