[Tutor] Python 3.2 - difference between out of dir() and help()

Steven D'Aprano steve at pearwood.info
Thu Mar 8 15:59:39 CET 2012


Flynn, Stephen (L & P - IT) wrote:

>                 All pretty standard stuff. I did however notice that the
> dir(x) told me about __class__, __reduce__ and __reduce_ex__ where the
> help(x) made no mention of them. Why is this difference? I presume the
> two commands using different means of getting at and displaying the
> methods for an object?

Yes. Both help() and dir() attempt to give an "interesting" list of 
attributes, and both have different ideas of what counts as "interesting".

There is no hard rules as to what they will give, consequently they may change 
from version to version. Any differences are unlikely to be deliberate, but 
merely side-effects of the specific implementation of each.

By the way, help() is a complete interactive environment. Just call help() 
with no arguments and follow the prompts.


>                 Is help() giving me all of the useful methods an object
> has which I'm encouraged to make use of, whereas dir gives me a complete
> list of everything that object can 'do' including those methods which
> aren't really meant for public consumption?

Nothing so specific.

See the documentation for both:

http://docs.python.org/library/functions.html#dir
http://docs.python.org/library/functions.html#help




-- 
Steven


More information about the Tutor mailing list