references and buffer()

km srikrishnamohan at gmail.com
Sun Oct 8 20:40:40 CEST 2006


Hi all,

was looking at references  in python...
>>> a = 10
>>> b = a
 >>> id(a)
153918788
>>>id(b)
153918788

where a and b point to the same id. now is this id an address ?
can one dereference a value based on address alone in python?
is id similar to the address of a variable or a class ?

read abt buffers as a refernce to a buffer object.
actually i tried passing list and dict types to buffer function, but only
with string type i could createa buffer reference,
>>>y = 'GATCGTACC'
>>>x = buffer(y, 0,8)
>>> x
<read-only buffer for 0xbf4cd3b8, size 8, offset 2 at 0xbf4cf0e0>
>>>print x
TCGTACC
>>> id(y)
-1085484104
>>> id(x)
-1085476384

now the ids of y and x are not the same - why ?
In which situatons are buffers used against the strings ?
can i create a write buffer instead of readonly buffer ?
what exactly are buffer object types ? and how can i instantiate them ?

regards,
KM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061009/455be630/attachment.html>


More information about the Python-list mailing list