You Are Here:

Community: Developer Discussion Boards

#1 Old how to initilize fixed size array in python S60 - 2009-01-28, 04:00

Join Date: Jan 2009
Posts: 64
Location: India
Send a message via AIM to pavan.pareta Send a message via MSN to pavan.pareta Send a message via Yahoo to pavan.pareta Send a message via Skype™ to pavan.pareta
pavan.pareta's Avatar
pavan.pareta
Offline
Regular Contributor
Hi All,

I am a new in python S60 development, i am also know in python has list or dictionary.but i don't know how to initialize fixed size array in python S60 language.

I am aware of c/c++/c# language.

such kind of thing in C/ C++ /C#

Example :

int age[4];
age[0]=23;
age[1]=34;
age[2]=65;
age[3]=74;


so please help me how can i initialize above example in python S60.

Thanks in advance


Pavan Pareta

http://www.croozeus.com/started.htm
Reply With Quote

#2 Old Re: how to initilize fixed size array in python S60 - 2009-01-28, 04:48

Join Date: May 2007
Posts: 2,738
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Hi Pavan,

Take a look at the array module, if you are specifically interested in arrrays. In python, we generally deal with lists. Arrays in python are lists with the identical type of elements.

Code:
a = array.array('i', xrange(5))
The above would define an array of 5 and initialize it with i (o to 4)
Reply With Quote

#3 Old Re: how to initilize fixed size array in python S60 - 2009-01-28, 06:26

Join Date: Feb 2008
Posts: 743
Location: Belo Horizonte, Brazil
Send a message via Skype™ to Rafael T.
Rafael T.'s Avatar
Rafael T.
Offline
Forum Nokia Champion
Quote:
Originally Posted by pavan.pareta View Post
Hi All,

I am a new in python S60 development, i am also know in python has list or dictionary.but i don't know how to initialize fixed size array in python S60 language.

I am aware of c/c++/c# language.

such kind of thing in C/ C++ /C#

Example :

int age[4];
age[0]=23;
age[1]=34;
age[2]=65;
age[3]=74;


so please help me how can i initialize above example in python S60.

Thanks in advance
Yes, like croozeus said, you can use lists in Python

An equivalent example for Python would be:

Code:
age = [0 for x in range(4)]
age[0] = 23
age[1] = 34
age[2] = 65
age[3] = 74
Hope it helps,

Rafael.
Last edited by Rafael T. : 2009-01-28 at 06:32.
Reply With Quote

#4 Old Re: how to initilize fixed size array in python S60 - 2009-01-28, 11:01

Join Date: Mar 2003
Posts: 937
Location: Espoo, Finland
JOM's Avatar
JOM
Offline
Forum Nokia Champion
Quote:
Originally Posted by pavan.pareta View Post
int age[4];
age[0]=23;
age[1]=34;
age[2]=65;
age[3]=74;
One more, much shorter:

Code:
age = [23, 34, 65, 74]
No need to allocate memory in advance or initialize into any specific value. When you define the array, you automatically allocate memory and initialize the values. This is what I especially like in python, it's perfectly ok to be lazy

Cheers,

--jouni
Reply With Quote

#5 Old Re: how to initilize fixed size array in python S60 - 2009-01-28, 12:27

Join Date: Jul 2008
Posts: 41
igordsm
Offline
Registered User
or you could use
Code:
age = [0]*4
wich gives you a list with 4 elements filled with zeros


http://igordsm.googlepages.com
Reply With Quote

#6 Old Thumbs up Re: how to initilize fixed size array in python S60 - 2009-01-29, 06:35

Join Date: Jan 2009
Posts: 64
Location: India
Send a message via AIM to pavan.pareta Send a message via MSN to pavan.pareta Send a message via Yahoo to pavan.pareta Send a message via Skype™ to pavan.pareta
pavan.pareta's Avatar
pavan.pareta
Offline
Regular Contributor
Hi All,

Thanks for your replied. This in information is help full for me.



Pavan Pareta

http://www.croozeus.com/started.htm
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Python for S60 1.4.1 released jplauril Python 30 2009-02-07 15:09
What can python do on s60? iamscuzzo Python 2 2008-11-06 06:06
S60 IrDA Python Extension (PLEASE HEEEELPPP) alistair9 General Symbian C++ 1 2008-06-05 13:18
[announce] the first Mobile Python book is now available ! cyke64 Python 1 2008-01-08 10:58
S60 3rd FP1 emulator scn size issues.. John.Holloway Symbian Tools & SDKs 0 2007-07-06 15:21

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia