这是什么要请我一个人为的例子:是否有可能在Python 2.6/Django1.3中有变量点访问器?
random_list = []
random_uuid = "1234567890-1234567890"
model_instance = Model.objects.filter(related_link=random_uuid)
for x in ['foo', 'bar', 'ray', 'mee']:
random_list.append(model_instance.x)
三个强制性问题:
- 这可能吗?
- 如果是这样怎么样?
- 有什么缺点吗?
也许这 '一堆' 例子可以帮助:HTTP://code.activestate。 com/recipes/52308-the-a-bunch-of-named/ – alemangui