Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass usingattributes

Discussion in 'Python' started by Ian Kelly, Dec 12, 2012.

  1. Ian Kelly

    Ian Kelly Guest

    On Wed, Dec 12, 2012 at 12:20 PM, Dave Cinege <> 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)
    Ian Kelly, Dec 12, 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:
    105
    Jason Friedman
    Dec 11, 2012
  2. Ian Kelly
    Replies:
    0
    Views:
    126
    Ian Kelly
    Dec 11, 2012
  3. Dave Cinege
    Replies:
    0
    Views:
    155
    Dave Cinege
    Dec 11, 2012
  4. Ian Kelly
    Replies:
    0
    Views:
    146
    Ian Kelly
    Dec 11, 2012
  5. Ian Kelly
    Replies:
    0
    Views:
    123
    Ian Kelly
    Dec 11, 2012
Loading...

Share This Page