![](https://secure.gravatar.com/avatar/8663ddbf163fccf1dd165e1359af3b63.jpg?s=120&d=mm&r=g)
I am wondering if there is any way to set an array as read-only, so that any trial to modify values of elements in the array raises some warning. Is it a cool feature to prevent unexpected side effect? Daehyok Shin (Peter)
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Fri, 2004-05-21 at 23:05, Shin, Daehyok wrote:
In numarray you can do this:
This works because of the buffer protocol and the fact that a string is a read-only buffer. Using the buffer protocol is a numarray feature so I'm pretty sure Numeric can't do this. Also note that in C, this read-only array is actually writable. Regards, Todd
![](https://secure.gravatar.com/avatar/faf9400121dca9940496a7473b1d8179.jpg?s=120&d=mm&r=g)
On Fri, 2004-05-21 at 23:05, Shin, Daehyok wrote:
In numarray you can do this:
This works because of the buffer protocol and the fact that a string is a read-only buffer. Using the buffer protocol is a numarray feature so I'm pretty sure Numeric can't do this. Also note that in C, this read-only array is actually writable. Regards, Todd
participants (2)
-
Shin, Daehyok
-
Todd Miller