Memoryview Attributes
memoryview.readonly
Indicate whether writing through this particular view is prohibited. Views over bytes are read-only; views over bytearray are normally writable. toreadonly() creates a read-only alias without freezing mutable storage or disabling writes through other aliases. This flag cannot be assigned directly. It describes access permission rather than a guarantee that values cannot change.
Formal Syntax & Structure
python syntaxpython
view.readonlyReturn Value
bool
True when writes through this view are prohibited.
Working Example
Example Snippetpython
data = bytearray(b"ABC")view = memoryview(data)read = view.toreadonly()print(view.readonly, read.readonly)data[0] = 90print(read.tobytes())