Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4036646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:14:56+00:00 2026-05-20T12:14:56+00:00

I have a container class (subclassed from list) where I have overridden the geattr

  • 0

I have a container class (subclassed from list) where I have overridden the geattr method;

def __getattr__(self, name):
    def _multiplexed(*args, **kwargs):
        return [getattr(R, name)(*args, **kwargs) for R in self]
    return _multiplexed

The trouble is that now I can’t ask Python for help about my object. When I do ask for help I get (traceback from iPython) the error which is copied below.

So the question is: How can I override getattr without losing my ability to call for help?

Thanks,
Jeremy

help(Collect)
/home/jlconlin/CustomPython/trunk/Collect.py in <module>()
----> 1 
      2 
      3 
      4 
      5 

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc in __call__(self, *args, **kwds)
    455     def __call__(self, *args, **kwds):
    456         import pydoc
--> 457         return pydoc.help(*args, **kwds)
    458 
    459 def sethelper():

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.pyc in __call__(self, request)
   1721     def __call__(self, request=None):
   1722         if request is not None:
-> 1723             self.help(request)
   1724         else:
   1725             self.intro()

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.pyc in help(self, request)
   1768             elif request: doc(request, 'Help on %s:')
   1769         elif isinstance(request, Helper): self()
-> 1770         else: doc(request, 'Help on %s:')
   1771         self.output.write('\n')
   1772 

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.pyc in doc(thing, title, forceload)
   1506     """Display text documentation, given an object or a path to an object."""
   1507     try:
-> 1508         pager(render_doc(thing, title, forceload))
   1509     except (ImportError, ErrorDuringImport), value:
   1510         print value

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pydoc.pyc in render_doc(thing, title, forceload)
   1483     desc = describe(object)
   1484     module = inspect.getmodule(object)
-> 1485     if name and '.' in name:
   1486         desc += ' in ' + name[:name.rfind('.')]
   1487     elif module and module is not object:

TypeError: argument of type 'function' is not iterable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:14:57+00:00Added an answer on May 20, 2026 at 12:14 pm

    Looking at the pydoc source code, the culprit is:

    getattr(thing, '__name__', None)
    

    That tries to look up thing.__name__, and if it fails, returns None instead. Except, in your case, it doesn’t fail; it gets a value back from __getattr__ instead.

    If you’re overriding __getattr__, it’s a good idea to special case all special attributes. Something like:

    if name.startswith("__"):
        raise AttributeError
    

    This ensures that if your class doesn’t have a particular special attribute (in this case, __name__), lookups for it will fail, rather than producing an unexpected value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dynamic class that serves as a storage container for configuration settings.
I have a class that contains a list of objects. What's the best way
I have a class that I need to binary serialize. The class contains one
I have an solution in VS 2008 which contains two class library projects and
I have a class that contains a dynamically allocated array, say class A {
I have a class that contains two methods like these: public String getFoo(Int32 a)
I have a class that contains an array. I want this array to be
I have a vector-like class that contains an array of objects of type T
I have a dll that contains a templated class. Is there a way to
I have a MATLAB class which contains a reference to a java object classdef

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.