This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
import datetime | |
class DBStore(abc.ABC): | |
@abc.abstractmethod | |
def connect(self): | |
return NotImplemented | |
@abc.abstractmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
class MySQLStore: | |
def connect(self): | |
print('connect to mysql database') | |
def serialize(self, first_name: str , last_name: str, birth: datetime, hourly_rate: int, labor_hours: int): | |
print('serialized data to mysql database') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dove(FlyableBird): | |
def walk(self): | |
return 0.1 | |
def fly(self): | |
return 10 | |
class Eagle(FlyableBird): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
class Walkable(abc.ABC): | |
@abc.abstractmethod | |
def walk(self): | |
return NotImplemented | |
class Flyable(abc.ABC): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Penguin(Bird): | |
def walk(self): | |
return 1 | |
def fly(self): | |
raise Exception('I cant fly') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dove(Bird): | |
def walk(self): | |
return 0.1 | |
def fly(self): | |
return 10 | |
class Eagle(Bird): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import abc | |
class Bird(abc.ABC): | |
@abc.abstractmethod | |
def walk(self): | |
return NotImplemented | |
@abc.abstractmethod | |
def fly(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SalesPerson(Employee): | |
@property | |
def bonus(self): | |
return self._bonus | |
@bonus.setter | |
def bonus(self, bonus): | |
self._bonus = bonus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class EmployeePrinterForHR: | |
def printCSV(employee: Employee): | |
print(u'{},{},{}'.format(employee.first_name, employee.last_name, employee.wage)) | |
class EmployeePrinterForIT: | |
def printCSV(employee: Employee): | |
print(u'{},{},{}'.format(employee.first_name, employee.last_name, employee.birth)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
class Employee: | |
// ... | |
def printForHR(self): | |
print(u'{},{},{}'.format(self.first_name, self.last_name, self.wage)) | |
def printForIT(self): | |
print(u'{},{},{}'.format(self.first_name, self.last_name, self.birth)) |
NewerOlder