[Numpy-discussion] numarray.records - get/set item

Colin J. Williams cjw at sympatico.ca
Thu Dec 4 17:08:29 EST 2003


Thanks, I've copied the list here.

Colin W.

Sebastian Haase wrote:

>Hi Colin,
>Did you also forget to cc that message to the mailing list - because I just
>realized that I send my second mail directly to Perry (only)
>[I'm not part of the "numarray-team" - so you would need to resent this
>message to the list ...]
>
>Regards,
>Sebastian
>
>----- Original Message ----- 
>From: "Colin J. Williams" <cjw at sympatico.ca>
>To: "Sebastian Haase" <haase at msg.ucsf.edu>
>Sent: Thursday, December 04, 2003 4:01 PM
>Subject: Re: [Numpy-discussion] numarray.records - get/set item
>
>
>  
>
>>Sebastian Haase wrote:
>>
>>    
>>
>>>Hi,
>>>Is it maybe a good idea to add this to the definition of 'class Record'
>>>
>>>class Record:
>>>   """Class for one single row."""
>>><snip>
>>>   def __getitem__(self, fieldName):
>>>       return self.array.field(fieldName)[self.row]
>>>   def __setitem__(self, fieldName, value):
>>>       self.array.field(fieldName)[self.row] = value
>>>
>>>I don't know  about the implications if  __delitem __  and so on are not
>>>defined.
>>>I just think it would look quite nice to say
>>>myRecArr[0]['mmm'] = 'hallo'
>>>as opposed to
>>>myRecArr[0].setfield('mmm',  'hallo')
>>>
>>>Actually I would even like
>>>myRecArr[0].mmm = 'hallo'
>>>
>>>This should be possible by defining __setattr__.
>>>It would obviously only work for fieldnames that do not contain '.' or '
>>>      
>>>
>'
>  
>
>>>or ...
>>>
>>>Any comments ?
>>>
>>>
>>>      
>>>
>>I prefer this, it requires fewer key strokes and should be easy to do.
>>
>>Colin W.
>>
>>
>>
>>    
>>
>
>
>  
>





More information about the NumPy-Discussion mailing list