Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass usingattributes (http://www.velocityreviews.com/forums/t955394-re-announce-thesaurus-a-recursive-dictionary-subclass-usingattributes.html)

Dave Cinege 12-11-2012 11:10 PM

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass usingattributes
 
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.



All times are GMT. The time now is 09:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.