473,387 Members | 1,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to create a writeable buffer?

I'm trying to create an object (as a C extension) to support the buffer
interface and was getting "TypeError: buffer is read-only" errors. So I
had a look at the array object and it has the same problem:

$ python
>>import array
a=array.array('c', ['a', 'b', 'c'])
a
array('c', 'abc')
>>a[0]
'a'
>>a[0]='d'
a
array('c', 'dbc')
>>buf=buffer(a)
buf[0]
'd'
>>buf[0]='e'
TypeError: buffer is read-only

The array is a mutable (writable) object, and the array implements the
buffer interface and provides a 'getwritebuf' method.
(Python-2.4.4/Modules/arraymodule.c has an array_buffer_getwritebuf())
so why does it give "TypeError: buffer is read-only"?

Steve
Nov 20 '06 #1
0 1755

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jerry | last post by:
Hi All: Is there any way I can get my script to be able to create and CHMOD folders and files??? I always get the following error: mkdir(TESTDIR): Permission denied in /usr/www/users... Is...
1
by: lawrence k | last post by:
I'm trying to write some RSS feeds. I've created a folder called rss, and it lives in the same directory as my scripts. I run the script and get no result. I put in a is_writeable() check and it...
1
by: Marco Shaw | last post by:
Is there something built-in to .net to determine if a directory is writeable by the current user? I want to write a Windows Powershell script that needs to write to a directory. I can certainly...
4
by: aki | last post by:
Hi all, i am writing codes for implementing network protocols. i have written a method which is receiving a packet from network. i have assumed that the packet i will receive will be of type...
1
by: jaleel | last post by:
In a windows application I have an xml file which is readable and writeable. I wnat to ensure that this file is writeable if it is set to read-only. I am doing my work using the code: ...
3
by: Tim Kelley | last post by:
Is there a way to determine if a CD/DVD is writeable? I have looked at using WMI (Win32_CDROMDrive) but it did not have any luck. Thanks.
3
by: 100grand | last post by:
Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price...
5
by: Gruik | last post by:
Hi people, I'm currently working on python embedding with C++. My goal is that the C++ part handle files writing/reading so that the Python part only works with buffers. I succeeded in buffer...
2
by: jarea | last post by:
I have read quite a bit about this error but I have yet to find the solution to my problem. I am trying to execute the following mysql statement: alter table line_items add...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.