From: Francesc A. <fa...@py...> - 2004-07-28 18:15:59
|
A Dimecres 28 Juliol 2004 15:59, Gerard Vermeulen va escriure: > Two points: > > 1. This is true for vanilla Python but not for IPython-0.6.2: > You see, the completion mechanism of ipython recognizes d['Francesc'] as an > integer. Ok. That's nice. IPython is more powerful than I realized :) > 2. If one accepts that a "field_name" can be used as an attribute, > one must be able to say: > > record.field_name ( == record.field("field_name") ) > > and (since recordArray[32] returns a record) also: > > recordArray[32].field_name > > and not > > recordArray[32].cols.field_name (sorry, I abhor this) Mmm, maybe are you suggesting that the records.Record class had all its methods starting by a reserved prefix (like "_" or better, "_v_" for attrs and "_f_" for methods), and forbid that field names would start by these prefixes so that no collision problems would occur with field names?. Well, in such a case adopting this convention for records.Record objects would be far more feasible than doing the same for records.RecArray objects just because the former has very few attrs and methods. I think it's a good idea overall. > > Anyway, as Russell suggested, I don't like recordArray["column"][32], > > because it would be unnecessary (you can get same result using > > recordArray[column_idx][32]). > > > > Thank you for this little slip, you mean recordArray["column"][32] is > recordArray[32][column_idx], isn't it? Uh, my bad. I was (badly) trying to express the same than Russell Owen on a message dated from 20th July: """ I think recarray[field name] is too easily confused with recarray[index] and is unnecessary. """ > I think that we agree that recordArray.cols["column"] is better than > recordArray["column"], but I don't see why recordArray.cols["column"] is > better than the original recordArray.field("column"). Good question. Me neither. You are proposing just keeping recordArray.cols.column as the only way to access columns? > PS: after reading the above, there may be a case to accept only indexing > which can be read from left to right, so > recordArray[32].field_name is OK, but recordArray.field_name[32] is not. Sorry, I don't see the point here (it is most probably my fault given the hours I'm writing this :(. May you elaborate that? Cheers, -- Francesc Alted |