×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    20

    import array not working

    Hi All.

    I wrote a class that makes use of the array module using python on my pc. I tried using the class on my s60 phone but it seems that the array module doesn't exist on the phone and as a result import array doesn't work.

    Can anybody tell me how i should go about using the array module on pys60.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: import array not working

    Quote Originally Posted by danieb_za View Post
    Hi All.

    I wrote a class that makes use of the array module using python on my pc. I tried using the class on my s60 phone but it seems that the array module doesn't exist on the phone and as a result import array doesn't work.

    Can anybody tell me how i should go about using the array module on pys60.
    hi danieb_za
    as far as i think there is no inbuilt module for arrays in PyS60. if u want to use it then there must be a extension for that.
    plz give feedback
    thanks.

  3. #3
    Regular Contributor
    Join Date
    Dec 2007
    Location
    India
    Posts
    133

    Re: import array not working

    Quote Originally Posted by danieb_za View Post
    Hi All.

    I wrote a class that makes use of the array module using python on my pc. I tried using the class on my s60 phone but it seems that the array module doesn't exist on the phone and as a result import array doesn't work.

    Can anybody tell me how i should go about using the array module on pys60.
    danieb, you are right the array module hasn't been ported to pys60.

    If you are looking to use the array you need to innitialize an array
    array_name=[]
    This will initialize a dynamic array named array_name that you can use.
    Kandyfloss

    V 7.0642.0
    18-10-06
    RH-51
    Nokia 7610

  4. #4
    Registered User
    Join Date
    Mar 2008
    Posts
    20

    Re: import array not working

    Hi.

    ----My old code using array----
    def getCheckSumBytes(self, bytes, offset):
    byteArray = array.array('B', bytes)

    byteArray[offset + 0] = ((self.C[0] - self.C[1]) & 255)
    byteArray[offset + 1] = ((self.C[1] - (self.C[0] << 1)) & 255)

    return byteArray

    ----New code using byteArray = []----
    def getCheckSumBytes(self, string, offset):
    byteArray = []

    for i in range(len(string)):
    byteArray.append(ord(string[i]))

    byteArray[offset + 0] = ((self.C[0] - self.C[1]) & 255)
    byteArray[offset + 1] = ((self.C[1] - (self.C[0] << 1)) & 255)

    return byteArray

    The problem is that i need to send byteArray using socket.send and socket.send doesn't accept a list as a parameter ( only accepts read only buffer or string)

    Any ideas?

  5. #5
    Registered User
    Join Date
    Mar 2008
    Posts
    20

    Re: import array not working

    Hi.

    Fixed with return str(byteArray) This converts a list to string ( so obvious!! )

  6. #6
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: import array not working

    Quote Originally Posted by danieb_za View Post
    Hi.

    Fixed with return str(byteArray) This converts a list to string ( so obvious!! )
    Good

    Array module is written in C++ so porting is needed for using with PyS60 ...

    BR
    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  7. #7
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: import array not working

    @cyke64
    hi cyke i hope u r thinking of writing an extension to port arrays into pys60.

Similar Threads

  1. GoogleIt
    By deepika.mangla in forum Symbian
    Replies: 5
    Last Post: 2011-05-28, 11:04
  2. J2Se Obex Server to receive files
    By alam.sher in forum Bluetooth Technology
    Replies: 22
    Last Post: 2008-07-17, 13:49
  3. Socket problem: Only nokia's phones got errors
    By n0cturnal in forum Mobile Java Networking & Messaging & Security
    Replies: 11
    Last Post: 2008-01-11, 10:32
  4. How to use m3g-package with J2ME Wireless Toolkit
    By fredand44 in forum Mobile Java Tools & SDKs
    Replies: 3
    Last Post: 2006-11-11, 00:50
  5. Nokia 6680 and InputStream OutputStream
    By eoghanconnolly in forum Bluetooth Technology
    Replies: 5
    Last Post: 2006-07-13, 05:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×