Finding stuff in the online docs

Alan McIntyre fusion at thuule.pair.com
Sun May 25 02:50:09 EDT 2003


Derek Fountain wrote:
 > I'm having trouble finding what I need in the online documentation,
 > which, in the absence of a Python book (maybe next payday) I'm stuck
 > with.

I picked up a copy of the Python Essential Reference and it's been very
valuable.  Just in case you were looking for a book recommendation. :)

 > I have these specific questions, and I'd like to know how to navigate
 > the online docs to find the answers:

I think the short answer is that you'll have to feel your way around
here: http://python.org/doc  until you get a feel for where topics will
turn up.  I spent a week or two doing a lot of reading there when I
first started using Python.

You can also try searching the online documentation: http://web.pydoc.org

 > The example code contains these lines at the top:
 >
 > import sys from qt import *
  >
  > What's the difference between the two forms of "import"?

'import sys' makes the objects in sys available in a 'sys' namespace;
for example, to find out what platform you're running you could do this:

print sys.platform

'from qt import *' makes the objects in qt available within the local
namespace.  Using the platform example from above, if you'd done a 'from
sys import *' or 'from sys import platform' instead of 'import sys', you
could print the platform description like this:

print platform

 > The example code contains this line:
 >
 > apply(QPushButton.__init__, (self,) + args)
 >
 > Where can I find information on the "apply" function? And, what is
 > the meaning of the (self,) thing? - the comma puzzles me.

Searching for "apply" turned up this link:
	http://web.pydoc.org/2.2/__builtin__.html#-apply

Basically the example you listed makes a call to the __init__ function
of QPushButton, passing as arguments a tuple containing 'self' and
whatever is contained in args.

The '(self,)' thing is a tuple with one item; args is presumably another
tuple, and '(self,) + args' just makes a single tuple to pass to
QPushButton.__init__.

 > If anyone would like to answer these questions here, that'd save me
 > some time. :o) But what I really want to know is how the search the
resources at
 > python.org (or elsewhere?) so I can find the answers to these issues,
 > and others, myself.

Since you're just getting started with Python, I would recommend just
digging through some basic Python-only tutorials and HOWTOs (like the
stuff listed at the bottom of http://python.org/doc) until you're more
familiar with the language, builtin functions and some of the standard
library modules.  Trying to mix PyQt in with it right off the bat
probably is making it difficult to find a place to start.

Hope this helps,
Alan







More information about the Python-list mailing list