News for hackers. Stuff that matters.
Re:Exactly-Once Initialization in Asynchronous Python by np_tedious on Saturday August 01, 2020 @07:24AM (#24019608)
Can you clarify what you mean by dependency injection in python? Did you mean a DI framework or something more informal?

I've seen DI frameworks in python but not really used them. At a glance they don't strike me as pythonic. Rolling your own kind of inversion of control can result in unruly "config" or "context" objects that bring difficulties as well.

Re:Exactly-Once Initialization in Asynchronous Python by fulafel on Saturday August 01, 2020 @08:42AM (#24020027)
DI is just a convoluted synonym for passing in arguments.
Re:Exactly-Once Initialization in Asynchronous Python by alexchamberlain on Sunday August 02, 2020 @03:46PM (#24031097)
Indeed. If you want it to be cleaner, a discipline of constructor arguments for injection and __call__ arguments for semantic input is really all you need.
Re:Exactly-Once Initialization in Asynchronous Python by oweiler on Saturday August 01, 2020 @07:40AM (#24019685)
Pass the fully constructed object as parameter. No need for a DI framework.
Re:Exactly-Once Initialization in Asynchronous Python by idclip on Saturday August 01, 2020 @07:45AM (#24019710)
I must say i havnt done any dependency injection in python. Did so in scala and JS though.

So i assume he means initilize it once in program entry and Pass in the pointer to the object that needs it via including it the constructor or a function call.

Do you think There’s a pythonic way of doing these things?