Re: help with this simple DB script

2006-05-16 Thread trebucket
This is probably causing a problem: !#/usr/bin/python It should be "#!", not "!#". If that doesnt' work, add this line at the top of your script, to check that the script is begin executed: print "Content-Type: text/html\n\n" print "Hello, World!" If you still get an Internal Server Error put t

Re: How to tell if function was passed a list or a string?

2006-05-17 Thread trebucket
>>> import types >>> type("") is types.ListType False >>> type("") is types.StringType True >>> type([]) is types.StringType False >>> type([]) is types.ListType True -- http://mail.python.org/mailman/listinfo/python-list

Problem with itertools.groupby.

2006-05-25 Thread trebucket
What am I doing wrong here? >>> import operator >>> import itertools >>> vals = [(1, 11), (2, 12), (3, 13), (4, 14), (5, 15), ... (1, 16), (2, 17), (3, 18), (4, 19), (5, 20)] >>> for k, g in itertools.groupby(iter(vals), operator.itemgetter(0)): ... print k, [i for i in g] ... 1 [(1, 11)]

Re: Multi-dimensional list initialization trouble

2006-05-25 Thread trebucket
An expression like this creates a list of integers: >>> [0] * 2 [0, 0] But an expression like this creates list of references to the list named `foo': >>> foo = [0, 0] >>> baz = [foo] * 2 [foo, foo] So, setting baz[0][0] = 1, is really setting foo[0] = 1. There is only one instance of foo, but y