[portland] Iterating Through Tuples In A List

Rich Shepard rshepard at appl-ecosys.com
Sat Feb 16 00:17:58 CET 2008

On Fri, 15 Feb 2008, kirby urner wrote:

> Remember that you can go:
> for row in self.appData.tsets:
>    print row

   Thank you.

> These look mutually consistent to me.  Do you have input into what
> data structure to use?  A dictionary might be better, e.g.
> {"HabitatComplexity":("Decay S-Curve", "Growth S-Curve"),
> "SpecialConcern":("Decay S-Curve", "Bell Curve", "Growth S-Curve"),
> "Variety":("Decay S-Curve", "Growth S-Curve")}
> Nevermind though.  Sounds like you've got something more like:
> [("HabitatComplexity" 2, ("Decay S-Curve", "Growth S-Curve")),
> ("SpecialConcern", 3, ("Decay S-Curve", "Bell Curve", "Growth S-Curve")),
> ("Variety", 2, ("Decay S-Curve", "Growth S-Curve"))]
> Number of subcomponents is sort of "data sugar" as it'd be easy
> to just get it from len, but oh well.

   The examples are portions of each tuple. They're retrieved from database
tables and each carries unique information.

> You could use your "Decay S-Curve" type strings (are they strings?)
> as pointers to plotting functions?

   That's exactly what I'm doing. Getting only the desired tuples to plot on
the same axes has been my hangup.

> Also, based on previous postings, I'm worried you don't really need "self"
> -- you're inside some class definition here?

   Yes. And row is referenced in several functions.


Richard B. Shepard, Ph.D.               |  Integrity            Credibility
Applied Ecosystem Services, Inc.        |            Innovation
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863

More information about the Portland mailing list