formations/python2/formation/snippets/patrons.py

19 lines
294 B
Python
Raw Normal View History

2013-05-15 10:47:55 +02:00
class NotFoundError(Exception):
pass
2013-01-08 11:15:45 +01:00
class MaClasse:
pass
class MaClasseDeux:
pass
2013-05-15 10:47:55 +02:00
binding = dict(un=MaClasse, deux=MaClasseDeux)
2013-01-08 11:15:45 +01:00
def ma_factory(key):
if key in binding:
return binding[key]()
else:
return NotFoundError("keskece?")