[Tutor] how to print array without adding newline
d at davea.name
Thu Sep 6 16:10:13 CEST 2012
On 09/06/2012 09: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
You top-posted, so I have to clip both the earlier messages out. On
this forum, we put responses immediately AFTER the part we quoted.
I don't see how I can possibly help further, without buying a hubot of
my own. I don't know what operating system you're running this on, nor
what the command lines look like. I have no idea how the stdout of your
script migrates over to the hubot's processor. Nor why it only gets
some of the stdout.
You could give us more environmental data (OS version, command line, any
messages, ...), or tell what the hubot's docs say you should use as a
> import cloudfiles
> import random
> import sys
> import array
> conn = cloudfiles.get_connection('username', 'key')
> containers = conn.get_all_containers()
> print "Content-type: text/html";
Perhaps you need a blank line to be output here. One way is just print
> # print sys.argv
> if "=" in sys.argv: sys.argv = sys.argv.rstrip("=")
> # print sys.argv
> del wholelist[int(sys.argv):]
> while i < int(sys.argv):
> i = i+1
> except IndexError, e:
Where do you alert the user about this exception?
> del newlist
> except Exception, err:
> print 'Caught an exception'
You should probably send this and any other error messages to stderr, as
stdout is presumably being consumed by the robot.
> print newlist,
More information about the Tutor