[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-23 Thread tb
tb added the comment: This is my use case: I am creating a custom DictReader class for reading and accessing the columns white space and case insensitive. For this I created a dict subclass (DictInsensitive) with a custom __getitem__ method. DictReaderInsensitive.__next__ overrides the

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You can overwrite fieldnames getter. @property def fieldnames(self): if self._fieldnames is None: try: self._fieldnames = next(self.reader) except StopIteration: pass

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-23 Thread tb
tb added the comment: Okay, that makes my use case obsolete. Overwriting the getter method like this seems obvious ... Somehow this hasn't come to my mind. Sorry for bothering. From my point of view, we can close this issue. Or is there another use case? --

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-23 Thread R. David Murray
R. David Murray added the comment: It does seem more logical to implement this in the getter, now that Serhiy has pointed it out :) So let's close this. (Aside: if it were me, I'd move the mangling of the fieldnames into the ListInsensitive __init__ method.) -- resolution: -

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-22 Thread Ramchandra Apte
Changes by Ramchandra Apte maniandra...@gmail.com: -- title: small fix to csv.DictReader.__init__ - make csv.DictReader.__init__ use self.fieldnames ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16297

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-22 Thread Berker Peksag
Berker Peksag added the comment: I think this is an invalid request. See the usage of property decorator: http://docs.python.org/py3k/library/functions.html#property -- nosy: +berker.peksag ___ Python tracker rep...@bugs.python.org

[issue16297] make csv.DictReader.__init__ use self.fieldnames

2012-10-22 Thread R. David Murray
R. David Murray added the comment: I think it is not an invalid request. However, what is the use case? Normally a class will manipulate the real variable, and the getter/setter is the public API. Without a good use case it doesn't seem worth changing that bit of the init method.