c******n 发帖数: 4965 | 1 【 以下文字转载自 Linux 讨论区 】
发信人: creation (努力自由泳50m/45sec !), 信区: Linux
标 题: discussion: why do we need entry_points in python (setup_tools) ?? --- and others
发信站: BBS 未名空间站 (Fri Oct 18 03:29:57 2013, 美东)
my impression is that it provides something similar to beans in java Spring,
so that other users can just grab your beans from your package.
but then it brings me to the very question of the point of using Spring
beans: why can't we simply use a factory class ? in fact in Spring
annotation-based configuration, you have something like :
@Bean(name="mybeanName")
MyBeanClass getMyBean() {
return ...
}
this is exactly a factory class , as we use them before Spring. the only
extra is adding this bean name associated with the factory method. such a
name only provides a syntactic sugar vs forcing the user code writer to
remember the factory class and method.
coming back to python,
instead of "load_entry_points('entry_name_id')" I could simply do
obj = namespace.package.Class.createObj('entry_name_id')
or am I missing something?
thanks |
|