Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-31 Thread Kent Johnson
Paul Kraus wrote: So now for all my reports all I have to write are little 5 or 6 line scripts that take a text file split the fields and format them before basing them off into my custom object. Very slick and this is my first python project. Its cluttered and messy but for about 1 hours

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-31 Thread Python
On Sat, 2005-12-31 at 09:33 -0500, Kent Johnson wrote: Could be self.results[key] = [0*24] [0]*24 Excellent points and advice, just noting a typo. -- Lloyd Kvam Venix Corp ___ Tutor maillist - Tutor@python.org

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-30 Thread Kent Johnson
Danny Yoo wrote: This being said, what data are you modeling? It almost sounds like you're implementing some kind of 3d matrix, even a sparse one. More information about the data you're modelling might lead to a different representation For example, would using a dictionary whose keys are

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-30 Thread Paul Kraus
That is the approach Paul took originally (see the other fork of this thread). He is accumulating a sparse 3d matrix where the keys are year, field6 and month. (He hasn't said what field6 represents.) The problem is that he wants to print out counts corresponding to all the existing year and

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-30 Thread Bill Burns
[snip] Paul Kraus wrote: Now I have to find a way to take the output at the end and pipe it out to an external Perl program that creates an excel spreadsheet ( no real clean easy way to do this in python but hey each tool has its usefullness). I wish I could hide this in the object though so

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-29 Thread Paul Kraus
On Wednesday 28 December 2005 11:30 am, Kent Johnson wrote: Python lists don't create new elements on assignment (I think Perl lists do this?) so for example dictionary[(key1, key2)][10] = X ok so assuming I had a dictionary with 1key that contained a list like so... dictionary[key1][0] How

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-29 Thread Danny Yoo
ok so assuming I had a dictionary with 1key that contained a list like so... dictionary[key1][0] How would I increment it or assign it if it didn't exist. I assumed like this. dict[key1][0] = dictionary.get(key1[0],0) + X Hi Paul, Given a dictionary d and some arbitrary key k, let's assume

[Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Paul Kraus
I am trying to build a data structure that would be a dictionary of a dictionary of a list. In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X I would iterate like so ... foreach my $key1 ( sort keys %dictionary ) { foreach my $key2 ( sort keys

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Paul Kraus
On Wednesday 28 December 2005 10:18 am, Paul Kraus wrote: I am trying to build a data structure that would be a dictionary of a dictionary of a list. In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X I would iterate like so ... foreach my $key1 ( sort keys

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Kent Johnson
Paul Kraus wrote: I am trying to build a data structure that would be a dictionary of a dictionary of a list. In Perl I would build the structure like so $dictionary{key1}{key2}[0] = X I would iterate like so ... foreach my $key1 ( sort keys %dictionary ) { foreach my $key2 ( sort

Re: [Tutor] Multi-Dimensional Dictionary that contains a 12 element list.

2005-12-28 Thread Kent Johnson
Paul Kraus wrote: Here is the code that I used. Its functional and it works but there has got to be some better ways to do a lot of this. Transversing the data structure still seems like I have to be doing it the hard way. The input data file has fixed width fields that are delimited by