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,
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
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.
--
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
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
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
-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
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
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
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
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,
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,
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
__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,
14 matches
Mail list logo