Skip Montanaro <[EMAIL PROTECTED]> added the comment:

Nick,

Working with Andrii's patch I'm trying to add a couple test cases to 
make sure the methods you and I both demonstrated still work.  Mine is 
no problem, but I must be doing something wrong trying to use/adapt your 
example.  I freely admit I am not an itertools user, but I can't get 
your example to work as written:

>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> r.fieldnames
['f1', 'f2', 'f3']
>>> r.next()
{'f1': '1', 'f2': '2', 'f3': 'abc'}
>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> first = next(r)
>>> first
{'f1': '1', 'f2': '2', 'f3': 'abc'}
>>> import itertools
>>> for x in itertools.chain(first, r):
...   print x
... 
f1
f2
f3

If I place first in a list it works:

>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> first = next(r)
>>> for x in itertools.chain([first], r):
...   print x
... 
{'f1': '1', 'f2': '2', 'f3': 'abc'}

That makes intuitive sense to me.  Is that what you intended?

S

_______________________________________
Python tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue3436>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to