[Tutor] arrays and strings

Andrei Kulakov ak@silmarill.org
Tue, 7 May 2002 10:18:41 -0400


On Mon, May 06, 2002 at 08:14:18PM +0500, wonderer@pakistanmail.com wrote:
> Hi can some one tell me how can we convert arrays to strings in python.
> I have seen functions like repr()and tostring() etc.
> I do it like this 
> def funcA ():
>  declare some array and assign some values
>  ....
>  showvalues(repr(array))
> 
> def showvalues(temp):
>  for index in range (0,5,1):
>   print "value ",temp[index]
>  
> and it never shows me the values that i inserted but shows the declaration of
> array element like a,r,r,y,(,",l,") and so on with elements.
> what i was really trying to do was use an array(of type we use in c) and then
> send that array to some function for processing but the dispaly is never as
> i want it to be.
>
You don't need to do anything with it to send it to some function:

>>> lst = [1,2,3,'a','b']
>>> def a(array):
...  for item in array:
...   print item
... 
>>> a(lst)
1
2
3
a
b


I hope this is what you wanted, but not too sure.. if this is not it,
please elaborate with some sample production code.

> 
> I will be really reallly reallly thankfull for your help and suggestions
> _______________________________________________________________________
> Get your free @pakistanmail.com email address   http://pakistanmail.com
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org