programming unlimited "categories" in python ?

Gabriel Ambuehl gabriel_ambuehl at buz.ch
Tue Oct 23 18:29:21 CEST 2001


-----BEGIN PGP SIGNED MESSAGE-----

Hello Lucio,

Tuesday, October 23, 2001, 6:08:48 PM, you wrote:

> i think the key in what he is asking is that he is not talking
> about ONE tree.  

So he want's to have like relational trees? Sounds like serious fun
to
implement.

> what if i have the followinf:

> region:
> 1- africa
> 1.1 mozambique
> 1.1.1 capital

> severity
> 1. deadly
> 1.1 next 5 hours
> 1.2 next ten days

> and you want a query like '5 hours deadly in africa'

You still need a link between the two, else you haven't got any
chance
to match them anyway so why not just build the region tree and store
all the data under it? then you query for africa first and fetch only
the results which have got the attribute deadly in 5 hours?

> problems with this:
> a) the categorization is not stored in the object, but in the tree
> that points at it. not so big a deal in SQL (you can select from
> all_trees where objectid = self), but what about python? how would
> you implement it?  

I wasn't thinking about the implementation itself but mostly about
suitable approaches. IMHO, you should try to squeeze your data model
into ONE tree and the problem is almost solved.

> b) africa can be pretty big. shouldnt i be able to get/(build?) the
> region tree under any node of the others? something like olap.


Uuh? Of course you can have africa as a subtree of some other tree if
you use some sort of generic tree class like:

class tree
      [some class] data
      list childs
      (pointer to parent)
      (pointer to next sibling)



Best regards,
 Gabriel


-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5i

iQEVAwUBO9WM1MZa2WpymlDxAQGxfAgAhW7j3v5EU9CHLojNlFAD/Yc/5dHLGTKi
Ra4wZh84CnjoqEmgpDVLAs2HGKFZe+jDrb7vVA03qfpeGz98k/wJ9JRL3r0MR07s
FSKqF4F8Nl2ppNLagu0ZMr4SA6m9CQ0Ur6pkNUjvk7ETu1mtiCMwFtRQ9hunEO9C
Zibf8h3dWMszy8zs75U06Fw9lUiMemEH4qTDB6t4PMQVpVXa4pX2XDcE5ApdEoxH
+9HuZmyGrGefIMfDJZK7e4tqv2/PjYVCMv9+2j3hDfL1+aZPI8DCDvRuQPKruR1n
qw0/40TddnYABhipzDPICBvOQ9hPwsS1O3f5DMh2MPDY7m9JM2tpeQ==
=p5+V
-----END PGP SIGNATURE-----





More information about the Python-list mailing list