Re: Array of dict or lists or ....?

2008-10-08 Thread Scott David Daniels
Pat wrote: I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States Counties Schools Classes Max Allowed Students Current enrolled Students Nebraska, Wabash,

Re: Array of dict or lists or ....?

2008-10-07 Thread Gabriel Genellina
En Mon, 06 Oct 2008 22:52:29 -0300, Tim Chase [EMAIL PROTECTED] escribió: __repr__ = __str__ [EMAIL PROTECTED] wrote] I don't know if that's a good practice. I've seen it in a couple places, and it's pretty explicit what it's doing. __repr__ is used as a fallback for __str__, so

Re: Array of dict or lists or ....?

2008-10-07 Thread Hrvoje Niksic
Tim Chase [EMAIL PROTECTED] writes: __repr__ = __str__ I don't know if that's a good practice. I've seen it in a couple places, and it's pretty explicit what it's doing. But what's the point? Simply define __repr__, and both repr and str will pick it up. --

Re: Array of dict or lists or ....?

2008-10-07 Thread Pat
Dennis Lee Bieber wrote: On Mon, 06 Oct 2008 19:45:07 -0400, Pat [EMAIL PROTECTED] declaimed the following in comp.lang.python: I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States

RE: Array of dict or lists or ....?

2008-10-07 Thread Barak, Ron
enrolled Students] = 0 ... Have an easy Yom Kippur, Ron. -Original Message- From: Pat [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 04:16 To: python-list@python.org Subject: Re: Array of dict or lists or ? Dennis Lee Bieber wrote: On Mon, 06 Oct 2008 19:45:07 -0400, Pat

Re: Array of dict or lists or ....?

2008-10-07 Thread Aaron Castironpi Brady
On Oct 7, 10:16 am, Barak, Ron [EMAIL PROTECTED] wrote: Would the following be suitable data structure: ... struct = {} struct[Nebraska] = Wabash struct[Nebraska][Wabash] = Newville struct[Nebraska][Wabash][Newville][topics] = Math struct[Nebraska][Wabash][Newville][Math][Max Allowed

RE: Array of dict or lists or ....?

2008-10-07 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Pat Sent: Tuesday, October 07, 2008 10:16 PM To: python-list@python.org Subject: Re: Array of dict or lists or ? The Perl routine works fine and I'd like to emulate that behavior

Re: Array of dict or lists or ....?

2008-10-07 Thread George Sakkis
On Oct 7, 10:15 pm, Pat [EMAIL PROTECTED] wrote: Dennis Lee Bieber wrote: On Mon, 06 Oct 2008 19:45:07 -0400, Pat [EMAIL PROTECTED] declaimed the following in comp.lang.python: I can't figure out how to set up a Python data structure to read in data that looks something like this

Re: Array of dict or lists or ....?

2008-10-07 Thread Ben Finney
George Sakkis [EMAIL PROTECTED] writes: On Oct 7, 10:15 pm, Pat [EMAIL PROTECTED] wrote: I don't understand why I need a database when it should just be a matter of defining the data structure. Picking an appropriate data structure depends on the kind of functionality you want to

Re: Array of dict or lists or ....?

2008-10-07 Thread Gabriel Genellina
En Tue, 07 Oct 2008 23:15:54 -0300, Pat [EMAIL PROTECTED] escribió: Dennis Lee Bieber wrote: On Mon, 06 Oct 2008 19:45:07 -0400, Pat [EMAIL PROTECTED] declaimed the following in comp.lang.python: I can't figure out how to set up a Python data structure to read in data that looks something

Array of dict or lists or ....?

2008-10-06 Thread Pat
I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States Counties Schools Classes Max Allowed Students Current enrolled Students Nebraska, Wabash, Newville,

Re: Array of dict or lists or ....?

2008-10-06 Thread Tim Chase
I can't figure out how to set up a Python data structure to read in data that looks something like this (albeit somewhat simplified and contrived): States Counties Schools Classes Max Allowed Students Current enrolled Students Nebraska, Wabash, Newville,

Re: Array of dict or lists or ....?

2008-10-06 Thread bearophileHUGS
Tim Chase: __repr__ = __str__ I don't know if that's a good practice. try: data.setdefault( state, {}).setdefault( county, {}).setdefault( cls, Attendence(max_students)).accrue(enrolled) except TooManyAttendants: I suggest to decompress

Re: Array of dict or lists or ....?

2008-10-06 Thread Tim Chase
__repr__ = __str__ I don't know if that's a good practice. I've seen it in a couple places, and it's pretty explicit what it's doing. try: data.setdefault( state, {}).setdefault( county, {}).setdefault( cls,