[Tutor] how to print array without adding newline
wrw at mac.com
wrw at mac.com
Fri Sep 28 15:35:58 CEST 2012
On Sep 6, 2012, at 9:49 AM, vicki at thepenguin.org wrote:
> Thank you for your reply. I understand that it is odd, but my program is being called from a hubot and returning data to it as well. I have figured out how to make the changes to get it to output the correct data in the correct format, but now I am getting a "Premature end of script headers" error. I have the correct #! line and the output from the command line shows no errors that would be interfering. Is there a way to make sure it is showing me all the errors? To increase error logging?
> ------
> !/usr/bin/env python
> import cloudfiles
> import random
> import sys
> import array
>
> conn = cloudfiles.get_connection('username', 'key')
>
> containers = conn.get_all_containers()
> i=0
> print "Content-type: text/html";
> wholelist=containers[0].list_objects()
> random.shuffle(wholelist)
> newlist=[]
> #newlist=wholelist[:]
> try:
> # print sys.argv[1]
> if "=" in sys.argv[1]: sys.argv[1] = sys.argv[1].rstrip("=")
> # print sys.argv[1]
> 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]
> except Exception, err:
> print 'Caught an exception'
> print newlist,
> -------
> Vicki
>
Python doesn't know what to do with:
!/usr/bin/env python
try
#!usr/bin/env python
so python doesn't see it, only the the shell.
-Bill
More information about the Tutor
mailing list