0

I have a wrapper around DB which provides some utility methods. An instance of DB wrapper is created once and accessible from a base class. I want to reuse this instance in a helper class, and was thinking about dependency injection due to my experience with OOP like C# or Java. However, with python I seem to lose intellisense support when I do this. I saw examples of dependency injection per function, however, this does not work for me, since a wrapper class has many different functions I want to use. What is the Python-ic way of achieving this?

oldbam
  • 2,397
  • 1
  • 16
  • 24

1 Answers1

0

The pythonic way is probably to pass the resource class as a parameter and rely on duck-typing... (you could probably create an abstract base class and multiply inherit it as a mixin to demonstrate that you know about interfaces, but if you want that kind of pain you probably shouldn't be coding in Python... ;-)

thebjorn
  • 26,297
  • 11
  • 96
  • 138