Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31709 > unrolled thread

Re: How to access the document for __call__ from command line?

Started byTerry Reedy <tjreedy@udel.edu>
First post2012-10-18 22:59 -0400
Last post2012-10-18 22:59 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to access the document for __call__ from command line? Terry Reedy <tjreedy@udel.edu> - 2012-10-18 22:59 -0400

#31709 — Re: How to access the document for __call__ from command line?

FromTerry Reedy <tjreedy@udel.edu>
Date2012-10-18 22:59 -0400
SubjectRe: How to access the document for __call__ from command line?
Message-ID<mailman.2492.1350615581.27098.python-list@python.org>
On 10/18/2012 10:30 PM, Peng Yu wrote:
> Hi,
>
> reference.pdf from python document has the following description. It
> is not accessible from help() in the command line. Is there an
> alternative so that I can quickly access these class attributes or
> method names from the command line?
>
> object.__call__(self [, args... ])
> Called when the instance is “called” as a function; if this method is
> defined, x(arg1, arg2, ...) is a
> shorthand for x.__call__(arg1, arg2, ...).

 >>> help(object.__call__)
Help on method-wrapper object:

__call__ = class method-wrapper(object)
  |  Methods defined here:
  |
  |  __call__(...)
  |      x.__call__(...) <==> x(...)
  |
snip not very helpful stuff

For a user class with a __call__ method with a docstring

 >>> class C:
	def __call__(self, x):
		"return the difference between self and x"
		return self-x

 >>> help(C.__call__)
Help on function __call__ in module __main__:

__call__(self, x)
     return the difference between self and x

Similarly for builtin methods you actually need to know about

 >>> help(list.append)
Help on method_descriptor:

append(...)
     L.append(object) -> None -- append object to end



-- 
Terry Jan Reedy

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web