How can i call array_length to get the length of array object?

gmspro gmspro at yahoo.com
Sat Jun 23 22:23:16 EDT 2012


Hi,

I tried this, 
>>> import array
>>> from array import array
>>> arr=array('i',[5,7,8])
>>> arr.sg_length
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'sg_length'
>>> arr=array('i'[5,8,7])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: string indices must be integers
>>> arr=array('i',[5,8,7])
>>> arr.length
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'length'
>>> arr.length()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'length'
>>> length(arr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'length' is not defined
>>> array_length(arr)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'array_length' is not defined
>>> arr.array_length()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'array_length'
>>> arr.array_length
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'array.array' object has no attribute 'array_length'

I'm trying to call this function, http://hg.python.org/cpython/file/3b7230997425/Modules/arraymodule.c#l657

Is that possible to call that function?

I know it's possible to do:
>>>len(arr)
>>>arr.itemsize

Any asnwer will be highly appreciated.

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120623/9104f455/attachment.html>


More information about the Python-list mailing list