Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass usingattributes

Discussion in 'Python' started by Dave Cinege, Dec 11, 2012.

  1. Dave Cinege

    Dave Cinege Guest

    On Tuesday 11 December 2012 17:39:12 Dave Cinege wrote:

    My memory is getting jogged more why did some things:

    raise KeyError(key + ' [%s]' % i)

    I did this to specificly give you the indice that failed recursion but provide
    the entire key name as it was provided to __getitem__

    So if:
    g.cfg.host.cpu
    fails recursion on 'host' you will see: g.cfg.host.cpu [2]
    I know my code sent g.cfg.host.cpu. I know host failed. if It was
    g.cfg.host.host, I'd know which host failed.

    Makes sense to me. Works for me. Sure there are other ways to do it.
     
    Dave Cinege, Dec 11, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Friedman
    Replies:
    0
    Views:
    116
    Jason Friedman
    Dec 11, 2012
  2. Ian Kelly
    Replies:
    0
    Views:
    136
    Ian Kelly
    Dec 11, 2012
  3. Dave Cinege
    Replies:
    0
    Views:
    165
    Dave Cinege
    Dec 11, 2012
  4. Ian Kelly
    Replies:
    0
    Views:
    155
    Ian Kelly
    Dec 11, 2012
  5. Ian Kelly
    Replies:
    0
    Views:
    135
    Ian Kelly
    Dec 11, 2012
Loading...

Share This Page