Russell Warren wrote:
> How can you tell what objects support the buffer interface?  Is
> anything visible at the python level, or do you need to dig into the C
> source?

At the C level, there is a function for testing:

int PyObject_CheckReadBuffer(PyObject* o)

http://docs.python.org/dev/api/abstract-buffer.html

According to

http://docs.python.org/dev/lib/non-essential-built-in-funcs.html

a Python call to buffer(obj) will either return a buffer object or (tested)
raise a TypeError:

   >>> buffer("123")
   <read-only buffer for 0x2b597d52b9c0, size -1, offset 0 at 0x2b597d52e340>
   >>> buffer(1)
   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   TypeError: buffer object expected

Stefan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to