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/t955431-re-announce-thesaurus-a-recursive-dictionary-subclass-usingattributes.html)

Ian Kelly 12-12-2012 08:42 PM

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass usingattributes
 
On Wed, Dec 12, 2012 at 12:20 PM, Dave Cinege <dave@cinege.com> wrote:
> On Tuesday 11 December 2012 01:41:38 Ian Kelly wrote:
>
>> I have a few critiques on the code. First, you might want to use
>> __getattribute__ instead of __getattr__. Otherwise you'll end up

>
> File "/home/dcinege/src/thesaurus/thesaurus.py", line 84, in
> __getattribute__
> return self.__getitem__(name)
> RuntimeError: maximum recursion depth exceeded while calling a Python object
>
> This takes me into the same hell as when I was trying to implement this as a
> class. Someone else would have to take the time to do this. __getattr__ doing
> what I expect it to do, for what i do.


def __getattribute__(self, name):
if name.startswith('__') and name.endswith('__'):
return super(Thesaurus, self).__getattribute__(name)
return self.__getitem__(name)


All times are GMT. The time now is 01:52 AM.

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