Skip to content

Instantly share code, notes, and snippets.

View AloyASen's full-sized avatar
💭
working remotely

Aloy Aditya Sen AloyASen

💭
working remotely
View GitHub Profile
@AloyASen
AloyASen / StrategyPattern.py
Created June 7, 2018 10:46
Example strategy pattern in Python
import math
class Metric(object):
"""Abstract class"""
def distance(self,x,y):
raise NotImplementedError("Derived classes should implement this.")
class EuclideanMetric(Metric):
"""Calculates distance from origin in R according to Pythagorean distance"""
def distance(self,x,y):