News for hackers. Stuff that matters.
Re:Python Default Dict by css on Wednesday May 05, 2021 @03:06PM (#27054245)
This is really cool, I used it to implement a (very) basic trie:

    trie_struct: Callable = lambda: defaultdict(trie_struct)

    trie = trie_struct()

    for word in words:
        ref = trie
        for char in word:
            ref = ref[char]
It won't work with words that substring other words, but its interesting.
Re:Python Default Dict by abcxjeb284 on Sunday May 09, 2021 @02:12AM (#27093662)
Nice! Very expressive way to do n-levels!