Skip to content

Instantly share code, notes, and snippets.

View AaronPhalen's full-sized avatar

@aaron_phalen AaronPhalen

View GitHub Profile
@AaronPhalen
AaronPhalen / singleton.py
Last active September 21, 2015 22:58
Shows basic usage of Python Singleton
# singleton.py illustrates how to use singleton design pattern in python
# influenced by Trevor Pain https://www.youtube.com/watch?v=6IV_FYx6MQA
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
# In python, a singleton is a design patter which allows once instance of a class to be invoked
# or stored in memory.
class Singleton(object):
_instance = None
def __new__(self):
@AaronPhalen
AaronPhalen / python_itertools.py
Last active April 21, 2020 03:26
Useful modules and examples from Python's itertools library.
# python_itertools.py highlights useful functions in python's itertools module
# Influenced by Raymond Chandler III pyvideo.org/video/2275 (Super Advanced Python Concepts)
# Author: Aaron Phalen | Twitter: @aaron_phalen | Email: [email protected]
from itertools import chain, combinations, permutations, compress, count, cycle, groupby
# 1. Itertools Chain Example
letters = ["a", "b", "c", "d"]
numbers = [1, 2, 3]
both = chain(letters, numbers)