formations/python/python2/formation/snippets/patrons.py
2018-08-21 10:26:27 +02:00

19 lines
294 B
Python

class NotFoundError(Exception):
pass
class MaClasse:
pass
class MaClasseDeux:
pass
binding = dict(un=MaClasse, deux=MaClasseDeux)
def ma_factory(key):
if key in binding:
return binding[key]()
else:
return NotFoundError("keskece?")