From: <ger...@gr...> - 2004-07-27 20:04:12
|
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=20 > > compatible with Python names, then I don't see that this is a problem= . =20 > > The question has been raised as to whether a wider range of names sho= uld=20 > > be permitted e.g.. including such characters as ~`()!=E7=E9=EB. My v= iew is=20 > > that such characters should be considered acceptable for data labels,= =20 > > but not for data names. i.e. they are for display, not for manipulati= on. >=20 > I finally was able to see your point. You mean that naming a field=20 > with a non-python identifier would be forbidden, and provide another=20 > attribute > (like 'title', for example) in case the user wants to add some kind=20 > of data label. Kind of: >=20 > records.array([...], names=3D["c1","c2","c3"], titles=3D["F one", > "time&dime","=E7=F2"]) >=20 > and have a new attribute called "titles" that keeps this info. >=20 > Well, I think that would be a very nice solution IMO. >=20 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 attribut= e 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 =3D 7 recordArray[32, column] Regards -- Gerard |