[Tutor] Tree Ctrl Data Structure - Help, please!

John Fouhy john at fouhy.net
Thu Jul 17 03:04:12 CEST 2008


On 17/07/2008, lauren at protopc.com <lauren at protopc.com> wrote:
>  Do you have any pointers on how to get from here
>
>  continent = ["australia", "europe", "america", "asia"]
>  country = [["spain", "germany", "belgium"], ["united states", "canada"]]
>  state = ["california", "oregon", "arizona"]
>
>  To here:
>
> geo=[
>     ("australia", []),
>     ("europe",
>         [("spain",[]),
>          ("germany",[]),
>
>          (belgium",[])]),
>
>     ("north america",
>         [("united states",[
>             ("california",[]),
>             ("oregon",[]),
>             ("arizona",[])
>             ])
>         ]),
>         ("canada", []),
>     ("asia", [])
>     ]
>
>  ??

Hi Lauren,

Basically, there is no way to do that because your lists don't contain
any information about which coutries corerspond to which continents,
et cetera.

>From looking at your other email, my guess is that you want to start
with SQL looking something like this:

select continent, country, state from world_globe

with the intention of getting back data that looks like:

[('America', 'United States', 'California'),
('America', 'United States, 'Texas'),
('America', 'United States, 'Washington'),
('America', 'Canada', 'Ontario'),
('Asia', 'Japan', None),
# etc
]

It would be fairly straightforward to take data looking something like
that and produce a tree.

-- 
John.


More information about the Tutor mailing list