Python-ic way to reuse instances in a way similar to dependency injection -


i have wrapper around db provides utility methods. instance of db wrapper created once , accessible base class. want reuse instance in helper class, , thinking dependency injection due experience oop c# or java. however, python seem lose intellisense support when this. saw examples of dependency injection per function, however, not work me, since wrapper class has many different functions want use. python-ic way of achieving this?

the pythonic way pass resource class parameter , rely on duck-typing... (you create abstract base class , multiply inherit mixin demonstrate know interfaces, if want kind of pain shouldn't coding in python... ;-)


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -