ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

Dave Cinege dave at cinege.com
Tue Dec 11 16:08:34 EST 2012


On Tuesday 11 December 2012 03:12:19 Steven D'Aprano wrote:

> Is this intended as a ready-for-production class?

For me, yes. In production code.

> py> d = Thesaurus()
> py> d['spam'] = {}

Maybe because spam is type dict instead of type thes???

>>> import thesaurus
>>> thes = thesaurus.Thesaurus
>>> t = thes()
>>> t.spam = thes()
>>> t.spam.ham = 'cheese'
>>> print t.spam.ham
>cheese
>>> print t['spam'].ham
>cheese
>>> print t['spam']['ham']
>cheese
>>> '%(spam.ham)s' % t
>'cheese'

Works for me!

Remainder of your post, not productive, not worth my time.

Dave



More information about the Python-list mailing list