recarray.__setattr__ bug?

Pierre GM pgmdevlist at gmail.com
Sat Oct 28 06:19:06 EDT 2006


On Friday 27 October 2006 22:18, Michael McNeil Forbes wrote:
> Is the following the desired behaviour for setting recarray attributes? 

I ran into the same problem recently...

What about modifying __setattr__ to the following ?

    def __setattr__(self, attr, val):
        fielddict = sb.ndarray.__getattribute__(self,'dtype').fields
        if attr in fielddict.keys():
            return sb.ndarray.__setitem__(self, attr, val)
        try:
            return object.__setattr__(self, attr, val)
        except AttributeError: # Must be a fieldname
            raise AttributeError, "record array has no attribute %s" % attr 

The order is changed, as in Michael's suggestion, but that doesn't set any 
variable in the __dict__, nor does it mask anything. Instead of modifying the 
an attribute, we modify the field directly...

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list