Static binding

20 views
Skip to first unread message

Krystian Kichewko

unread,
Oct 12, 2015, 10:47:48 AM10/12/15
to python-inject
Hello!

I was looking into python-inject, but I can't find a way to do static binding:

This is how it works in python-inject right now:

class Foo:
    pass

def my_configure(binder):
    binder.bind(Foo, Foo())
    binder.bind_to_constructor(Foo, Foo)

inject.configure(my_configure)


I would like to do something else:

class Foo:
    pass
inject.bind(Foo, Foo())


Is it feasible to do in python-inject? I checked the source and it doesn't seem I can call inject.configure multiple times, because it will raise an exception. Basically I would to bind and configure stuff the same way I inject them, using just the module: inject.bind, inject.bind_to_constructor.


Thanks, and thanks for python-inject!

Krystian Kichewko

Ivan Korobkov

unread,
Oct 12, 2015, 3:54:14 PM10/12/15
to python...@googlegroups.com
Hi!
No, it is not possible to do static binding in python-inject. Frankly speaking, I think static binding is a bad thing. It's like having a lot of global variables scattered around the code. python-inject instead provides a way to have reusable composable modules/functions.

--
You received this message because you are subscribed to the Google Groups "python-inject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-injec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Ivan Korobkov
ivan.k...@gmail.com
Reply all
Reply to author
Forward
0 new messages