Skip to content

Instantly share code, notes, and snippets.

@denhartog
denhartog / grouper.py
Last active August 29, 2015 14:18
grouper
from itertools import zip_longest, islice
def grouper(iterable, n):
return zip(*[iter(iterable)] * n)
def grouper_longest(iterable, n, fillvalue=None):
return zip_longest(*[iter(iterable)] * n, fillvalue=fillvalue)
i0 = []
i1 = [1]
@denhartog
denhartog / design patterns
Created May 28, 2015 19:46
design patterns
#https://github.com/faif/python-patterns
Facade # https://github.com/faif/python-patterns/blob/master/facade.py
Factory Method # https://github.com/faif/python-patterns/blob/master/factory_method.py
MVC # https://github.com/faif/python-patterns/blob/master/mvc.py
Tier # https://github.com/faif/python-patterns/blob/master/3-tier.py
Publish/Subscribe # https://github.com/faif/python-patterns/blob/master/publish_subscribe.py