From: Travis O. <oli...@ee...> - 2006-07-10 23:10:05
|
John Parejko wrote: >Howdy! I just wanted to voice my agreement with this statment by Erin Sheldon: > > > I brought up the issue a while back of having a simple way to > > access the field names of an array. The quick summary: accessing > > field names has some oddness that needs cleaning up. > >Sometimes a['name'], sometimes a.field('name'). I vastly prefer the first >version; it has become my favored way of dealing with my FITS and ASCII >data. But using the bracket notation sometimes gives an error, and I >haven't quite figured out what the circumstances are. > > Bracketed version should never give an error. If you see it, it's a bug. >Also, "for name in a.dtype.fields:" or "for name in a.fields:" would be >very, very handy. > > You can do this, now but each key in the fields dictionary might not be unique because titles will also be keys in the dictionary. A unique list of ordered names can now (in NumPy SVN) be obtained using for name in a.dtype.names -Travis |