Jon Clements a écrit : > Hi Group, > > If I have a CSV reader that's passed to a function, is it possible for > that function to retrieve a reference to the "fileobj" like object > that was passed to the reader's __init__? For instance, if it's using > an actual file object, then depending on the current row, I'd like to > open the file object again, seek to the current position, then create > a csv.reader on that, exhaust it until a certain point, then return. > ie, leaving the passed iterator intact and ready to carry on as > normal. > > (And yes, I know passing in the source object is probably easier -- > assume a constraint that I can't...) >
As Skip pointed out, this won't work that way. There might be a possible workaround using itertools.tee and eventually StringIO. My 2 cents -- http://mail.python.org/mailman/listinfo/python-list