Design pattern in python