You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
I can't figure out a way to assign values to class with default init values.
Example as below.
I expect the output to be 'bbb' instead of 'B'.
Am I missing something? please help.
import pinject
class A(object):
def __init__(self, a, b='B'):
self.a=a
self.b=b
class B(object):
def __init__(self, obja):
self.obja = obja
def printit(self):
print(self.obja.a)
print(self.obja.b)
class MyBindingSpec(pinject.BindingSpec):
def configure(self, bind):
bind('obja',to_class=A)
bind('a',to_instance='aaa')
bind('b',to_instance='bbb')
obj_graph = pinject.new_object_graph(binding_specs=[MyBindingSpec()])
objb = obj_graph.provide(B)
objb.printit()
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I can't figure out a way to assign values to class with default init values.
Example as below.
I expect the output to be 'bbb' instead of 'B'.
Am I missing something? please help.
The text was updated successfully, but these errors were encountered: