1.下面这行代码中,[obj]是对象列表吗?没有读懂下面代码的这一处。
从运行上看,[obj]的确是可迭代的iterable。
在run.py中
obj=TR_OBJ(seq,labels,name=sys.argv[1])
tr_obj_list=[obj]
for o in tr_obj_list: # obj仅仅是一个对象吗?
do_something(o.seq)
关于TR_OBJ的类定义
class TR_OBJ:
''' define a trainable object, a TR_OBJ object cositst of:
self.seq # the list of symbols || vectors
self.labels # the list of the labels
self.name # the object name
……
'''
def __init__(self, seq, labels=[], f=[], b=[], eMat=[], scale=[], p=None, name=None):
self.seq = seq # the list of symbols || vectors
self.labels = labels # the list of the labels
self.name = name # the object name
……
Saya tidak begitu memahami soalan anda
Tetapi
[obj]
hanyalah senarai, jadi sudah tentu ia boleh diulang!Soalan yang saya jawab: Python-QA