Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34647

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

From Dave Cinege <dave@cinege.com>
Subject Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes
Date 2012-12-11 16:08 -0500
References <mailman.705.1355198321.29569.python-list@python.org> <50c6eae2$0$21722$c3e8da3$76491128@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.743.1355260121.29569.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Dave Cinege <dave@cinege.com> - 2012-12-10 22:48 -0500
  Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-11 08:12 +0000
    Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Dave Cinege <dave@cinege.com> - 2012-12-11 16:08 -0500
      Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-12 06:34 +0000
      Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-12 06:34 +0000
        Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Chris Angelico <rosuav@gmail.com> - 2012-12-12 17:44 +1100
        Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes "D'Arcy J.M. Cain" <darcy@druid.net> - 2012-12-12 05:25 -0500
  Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Dave Cinege <dave@cinege.com> - 2012-12-12 13:13 -0500
  Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-12-12 23:56 +0000
    Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-13 00:15 +0000

csiph-web