Quick Reference from module doc strings.

Ron Adam rrr at ronadam.com
Sun May 15 20:44:36 EDT 2005


John Machin wrote:
> Ron Adam wrote:
> 
>>Does anyone have suggestions on how to improve this further?
> 
> 
> Not functionally (from me, yet). However if you can bear a stylistic
> comment, do read on :-)
> 
> 
>>         elif (isinstance(object,str)
>>                 or isinstance(object,int)
>>                 or isinstance(object,bool)
>>                 or isinstance(object,tuple)
>>                 or isinstance(object,list)
>>                 or isinstance(object,dict)):
> 
> 
> Since Python version 2.2, the 2nd arg of isinstance may be a tuple. You
> could define this up front, with a meaningful name:
> 
> TYPES_WHICH_whatever = (str, int, bool, etc etc)
> 
> Cheers,
> John

Actually I'm begging for comments, it's the beginning of a project not 
the end.  So thanks!  ;-)

I changed it to:

    if type(object)==str:
        ....
    elif type(object) in (str,int,bool,tuple,list,dict):
        ....

Thanks, I don't need the isinstance(), type works here just as well.

What would it take to make it useful?  I'm thinking of putting it to use 
in a database where you can get quickly get info by subject and 
keywords, not just by module.  I'm also thinking of using it to generate 
web pages.

As far as the actual content of doc strings for each item, we can submit 
requests for improvements where it's needed.

Cheers,
_Ron




More information about the Python-list mailing list