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

Discussion in 'Python' started by Ignacio Mondino, Jun 24, 2012.

  1. On Sat, Jun 23, 2012 at 11:23 PM, gmspro <> wrote:
    >
    > 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.
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    Hi,

    something along the lines
    >>> s = 'supercalifragilisticexpialidocious'
    >>> len(s)

    34

    check http://docs.python.org/ for more on this.

    Ignacio
    Ignacio Mondino, Jun 24, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mitchua
    Replies:
    5
    Views:
    2,731
    Eric J. Roode
    Jul 17, 2003
  2. Ian Kelly
    Replies:
    0
    Views:
    221
    Ian Kelly
    Jun 24, 2012
  3. Stefan Behnel
    Replies:
    0
    Views:
    220
    Stefan Behnel
    Jun 24, 2012
  4. Mark Lawrence
    Replies:
    2
    Views:
    252
    Terry Reedy
    Jun 25, 2012
  5. Antoon Pardon
    Replies:
    0
    Views:
    232
    Antoon Pardon
    Jun 25, 2012
Loading...

Share This Page