So I wanted to make an arff reader (similar to csv file format).
And I wanted to use yield to make an iterator but also to add attributes to this iterator.
eg:
data = arff.reader(my_fname)
print data.relation
for row in data:
print row
but in the reader definition:
def reader(fname):
reader.relation = fname # this is assigned to the function, not the generator
yield 1
yield 2
Is there a way to do this using yield or am I stuck with the iterator api?
You can make it a class.