[issue3436] csv.DictReader inconsistency

2008-08-08 Thread Barry A. Warsaw
Barry A. Warsaw [EMAIL PROTECTED] added the comment: Making an existing attribute a property is a nice, API-neutral way to handle this. Let's call the inconsistency a bug and this a bug fix wink so that it's fine to add to 2.6 and 3.0 at this point. -- nosy: +barry resolution: -

[issue3436] csv.DictReader inconsistency

2008-08-08 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: Committed as revision 65605. -- assignee: - skip.montanaro status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-08-01 Thread Andrii V. Mishkovskyi
Andrii V. Mishkovskyi [EMAIL PROTECTED] added the comment: Oh, so this is how the process looks like... /me removes patches I've uploaded both py3k and trunk patches just because I'm fixing things the other way round -- first I write a patch for 3.0 and only after that I backport it to 2.6.

[issue3436] csv.DictReader inconsistency

2008-08-01 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file11016/issue3436.py3k.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-08-01 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file11017/issue3436.trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-08-01 Thread Nick Coghlan
Nick Coghlan [EMAIL PROTECTED] added the comment: Skip's patch looks good to me (as Skip discovered, I left out the necessary step of putting the first row back into an iterable before invoking chain in my example code) ___ Python tracker [EMAIL PROTECTED]

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Nick Coghlan
Nick Coghlan [EMAIL PROTECTED] added the comment: I personally like the idea of making fieldnames a property - while having merely reading an attribute cause disk I/O is slightly questionable, it seems like a better option than returning a misleading value for that property and also a better

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Added file: http://bugs.python.org/file11016/issue3436.py3k.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Added file: http://bugs.python.org/file11017/issue3436.trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Andrii V. Mishkovskyi
Andrii V. Mishkovskyi [EMAIL PROTECTED] added the comment: I like the idea of fieldnames attribute being a property, so i've uploaded patches that implement them as such. Both patches ran through make test without problems. ___ Python tracker [EMAIL

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Skip Montanaro
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

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: I added a comment to Andrii's patch and added simple test cases which check to make sure the way Nick and I currently use the DictReader class (or at least envision using it) still works. Added file: http://bugs.python.org/file11021/csv.diff

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Skip Montanaro
Changes by Skip Montanaro [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file10978/csv.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___ ___

[issue3436] csv.DictReader inconsistency

2008-07-31 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: Andrii, If my view of the Python 3.0 development process is correct and this change makes it into the 2.6 code, one of the 3.0 developers will merge to the py3k branch. ___ Python tracker [EMAIL PROTECTED]

[issue3436] csv.DictReader inconsistency

2008-07-30 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file10967/trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-30 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file10965/py3k.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-30 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: Guido I know this has been closed, but perhaps the fieldnames attribute Guido could be made into a property that reads the first line of the Guido file if it hasn't been read yet? It's a nice thought. I tried the straightforward

[issue3436] csv.DictReader inconsistency

2008-07-30 Thread Nick Coghlan
Nick Coghlan [EMAIL PROTECTED] added the comment: Re-opened for consideration of GvR's suggestion. -- resolution: wont fix - status: closed - open ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436

[issue3436] csv.DictReader inconsistency

2008-07-29 Thread Guido van Rossum
Guido van Rossum [EMAIL PROTECTED] added the comment: I know this has been closed, but perhaps the fieldnames attribute could be made into a property that reads the first line of the file if it hasn't been read yet? -- nosy: +gvanrossum ___ Python

[issue3436] csv.DictReader inconsistency

2008-07-28 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: The consensus seems to be that __init__ shouldn't magically read the header row, even though by not specifying a fieldnames arg that's exactly what you're telling the DictReader where to find the column headers. Given that case, my argument is

[issue3436] csv.DictReader inconsistency

2008-07-28 Thread Andrii V. Mishkovskyi
Andrii V. Mishkovskyi [EMAIL PROTECTED] added the comment: I'm ok with that. :) Looks like you can close this one as won't fix. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-28 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: Done... -- resolution: - wont fix status: open - closed ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-26 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: I should also point out that I've generally used this technique to populate the fieldnames attribute from the file: f = open(somefile.csv, rb) rdr = csv.DictReader(f, fieldnames=csv.reader(f).next()) So it is fairly trivial to set

[issue3436] csv.DictReader inconsistency

2008-07-26 Thread Nick Coghlan
Nick Coghlan [EMAIL PROTECTED] added the comment: Like Raymond, I have issues with the idea of implicitly reading the headers in __init__, but would be fine with the idea of a separate method in 2.7/3.1. As far as working around the absence of such a method goes, I personally use

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
New submission from Andrii V. Mishkovskyi [EMAIL PROTECTED]: I had to use csv module recently and ran into a problem with DictReader. I had to get headers of CSV file and only after that iterate throgh each row. But AFAIU there is no way to do it, other then subclassing. So, basically, right now

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Added file: http://bugs.python.org/file10966/trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Removed file: http://bugs.python.org/file10966/trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: Added file: http://bugs.python.org/file10967/trunk.csv.py.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
Changes by Andrii V. Mishkovskyi [EMAIL PROTECTED]: -- components: +Library (Lib) type: - behavior ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3436 ___

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Raymond Hettinger
Raymond Hettinger [EMAIL PROTECTED] added the comment: I think this is the wrong approach. It would be better to have a separate getheader() method. Having __init__ do the deed is at odds with other uses of __init__ that only do setup but don't start reading. -- nosy: +rhettinger

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Andrii V. Mishkovskyi
Andrii V. Mishkovskyi [EMAIL PROTECTED] added the comment: And how this method should look? Something like this, I suppose: def getheader(self): if self.fieldnames is None: try: self.fieldnames = self.reader.next() except StopIteration: pass

[issue3436] csv.DictReader inconsistency

2008-07-24 Thread Skip Montanaro
Skip Montanaro [EMAIL PROTECTED] added the comment: That would be a fairly easy change to the DictReader class (see the attached patch) but probably can't be applied at this point in the 2.6 release cycle even though all csv module tests pass with it. -- nosy: +skip.montanaro Added