On May 15, 9:25 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>,
>
> [EMAIL PROTECTED] wrote:
> > If I have the tree in the dictionary, the code would like this,
> > def search(tree, path):
> >while path and not(tree.haskey(path)):
> > path = path[:-1]
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> If I have the tree in the dictionary, the code would like this,
> def search(tree, path):
>while path and not(tree.haskey(path)):
> path = path[:-1]
>if path:
> return tree[path]
>else:
> raise KeyError('path
On May 15, 6:33 pm, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> In <[EMAIL PROTECTED]>,
>
>
>
> [EMAIL PROTECTED] wrote:
> > I use these names as keys in a dictionary, and store node's data.
> > Now given a name like "abc", I want to find the key with the following
> > rule:
> > If the ke
In <[EMAIL PROTECTED]>,
[EMAIL PROTECTED] wrote:
> I use these names as keys in a dictionary, and store node's data.
> Now given a name like "abc", I want to find the key with the following
> rule:
> If the key exists return the value
> If the key does not exist, return the value of the leaf node