how to print array without adding newline

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to print array without adding newline

vickistan
This post has NOT been accepted by the mailing list yet.
Hello: I am trying to output an array to another program that takes an array as input, but the print statement adds a newline. If it were adding to each individual element, I could solve it easily, but it is adding one at the end of the array. Is there another way to print an array besides

print arrayname

If it were a string, I have a whole host of options, but I need it to be output as an array. Each element is a url. I call it from a browser, and it works except for the added newline.

Here are the relevant lines:

=================
/* code that connects to cloudfiles omitted */

containers = conn.get_all_containers()
i=0
print "Content-type: text/html\n\n";
wholelist=containers[0].list_objects()
random.shuffle(wholelist)
newlist=[]
try:
    del wholelist[int(sys.argv[1]):]
    while i < int(sys.argv[1]):
        newlist.append("http://example.com/"+wholelist[i].rstrip())
        i = i+1
except IndexError, e:
    del newlist[5]
print newlist
==============

The output I am seeing is as follows:

['http://example.com/wet-longhaireddachshund.jpg', 'http://example.com/dachshund2.jpg', 'http://example.com/dachshundingrass.jpg']

Any tips on better coding practices are welcome, but please don't beat me up

Thanks,
vickistan
Loading...