[Tutor] how to print array without adding newline

vickistan vicki at stanfield.net
Sun Aug 19 03:17:24 CEST 2012


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




--
View this message in context: http://python.6.n6.nabble.com/how-to-print-array-without-adding-newline-tp4985646.html
Sent from the Python - tutor mailing list archive at Nabble.com.


More information about the Tutor mailing list