Have you tried a conditional/try-catch block in your __init__? Something like
class MyDBConn(object): def __init__(self, **db_kwargs): try: db = some_db.connect(**db_kwargs) except some_db.ConnectionError: db = my_fake_db() finally: self.db = db You might have to write an adapter to make sure you can treat the fake db and real db the same way, but that shouldn't be too hard. -- https://mail.python.org/mailman/listinfo/python-list