On Tue, 27 Jul 2004 20:46:52 +0200, Francesc Alted wrote
A Dimarts 27 Juliol 2004 20:21, Colin J. Williams va escriure:
If one starts with the assumption that field/attribute names are compatible with Python names, then I don't see that this is a problem. The question has been raised as to whether a wider range of names should be permitted e.g.. including such characters as ~`()!çéë. My view is that such characters should be considered acceptable for data labels, but not for data names. i.e. they are for display, not for manipulation.
I finally was able to see your point. You mean that naming a field with a non-python identifier would be forbidden, and provide another attribute (like 'title', for example) in case the user wants to add some kind of data label. Kind of:
records.array([...], names=["c1","c2","c3"], titles=["F one", "time&dime","çò"])
and have a new attribute called "titles" that keeps this info.
Well, I think that would be a very nice solution IMO.
I agree with Rick, Colin and Francesc on this point: symbolic names are important and I like the commandline completion too. However, I have another concern: Introducing recordArray["column"] as an alternative for recordArray.field("column") breaks a symmetry between for instance 1-d record arrays and 2-d normal arrays. (the symmetry is strongly suggested by their representation: a record array prints almost as a list of tuples and a 2-d normal array almost as a list of lists). Indexing a column of a 2-d normal array is done by normalArray[:, column], so why not recArray[:, "column"] ? It removes the ambiguity between indexing with integers and with strings. Also, leaving the indices in 'natural' order becomes especially important when one envisages (record) arrays containing (record) arrays containing .... I understand that this seems to open the door to recArray[32, "column"], but if it is really not feasible to mix integers and strings (or attribute names) as indices, I prefer to use recordArray.column[32] and/or recordArray[32].column rather than recordArray["column"][32]. Even indexing with integers only seems more natural to me than eg. recordArray["column"][32], sincy I can always do: column = 7 recordArray[32, column] Regards -- Gerard