Hi, On Wed, 16 Jan 2008 06:23:10 -0800 (PST), "mlimber" <[EMAIL PROTECTED]> said: > I'm writing a text processing program to process some survey results. > I'm familiar with C++ and could write it in that, but I thought I'd > try out Python. I've got a handle on the file I/O and regular > expression processing, but I'm wondering about building my array of > classes (I'd probably use a struct in C++ since there are no methods, > just data).
You could try something like this. #!/usr/bin/env python class Response: def __init__(self, name, age, iData, sData): self.name = name self.age = age self.iData = iData self.sData = sData def sourceOfResponses(): return [["you", 42, [1, 2, 3], ["foo", "bar", "baz"]], ["me", 23, [1, 2, 3], ["ham", "spam", "eggs"]]] if __name__ == "__main__": responses = [] for input in sourceOfResponses: response = Response(input.name, input.age, input.iData, input.sData) reponses.append(response) Lutz -- GnuPG Key: 1024D/6EBDA359 1999-09-20 Key fingerprint = 438D 31FC 9300 CED0 1CDE A19D CD0F 9CA2 6EBD A359 http://dev-random.dnsalias.net/0x6EBDA35.asc http://pgp.cs.uu.nl/stats/6EBDA359.html -- http://mail.python.org/mailman/listinfo/python-list