[Tutor] Documentation

Andre Roberge andre.roberge at gmail.com
Mon Feb 6 03:45:40 CET 2006


On 2/5/06, Paul Kraus <pkraus at pelsupply.com> wrote:
> I have been working through a couple of books and learning alot. However I
> can't seem to find any easy way to learn more about different methods and
> commands.
>
> For instance what are all of the methods that can be applied to lists and what
> do they do and how do they work. Or in TKinter what are all the different
> things can I do with a button besides just setting the command and the text
> and such. These are just examples.
>
> I can't find an easy way to do this.
>
Python is your friend!    Here's the (truncated) result of an
interactive session.

PythonWin 2.4.2 (#67, Oct 30 2005, 16:11:18) [MSC v.1310 32 bit
(Intel)] on win32.
Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au)
- see 'Help/About PythonWin' for further copyright information.
>>> a = []
>>> dir (a)
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
'__delslice__', '__doc__', '__eq__', '__ge__', '__getattribute__',
'__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__',
'__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
'__setslice__', '__str__', 'append', 'count', 'extend', 'index',
'insert', 'pop', 'remove', 'reverse', 'sort']
>>> help(a.index)
Help on built-in function index:

index(...)
    L.index(value, [start, [stop]]) -> integer -- return first index of value

>>> import Tkinter
>>> dir(Tkinter)
['ACTIVE', 'ALL', 'ANCHOR', 'ARC', 'At', 'AtEnd', 'AtInsert',
'AtSelFirst', 'AtSelLast', 'BASELINE', 'BEVEL', 'BOTH', 'BOTTOM',
'BROWSE', 'BUTT', 'BaseWidget', 'BitmapImage', 'BooleanType',
'BooleanVar', 'BufferType', 'BuiltinFunctionType',
'BuiltinMethodType', 'Button',

[snip]

>>> dir(Tkinter.Button)
['_Misc__winfo_getint', '_Misc__winfo_parseitem', '__doc__',
'__getitem__', '__init__', '__module__', '__setitem__', '__str__',
'_bind', '_configure', '_displayof', '_do', '_getboolean',
'_getdoubles', '_getints', '_grid_configure', '_nametowidget',
'_noarg_', '_options', '_register', '_report_exception', '_root',
'_setup', '_subst_format', '_subst_format_str', '_substitute',

[snip]

>>> help(Tkinter.Button.configure)
Help on method configure in module Tkinter:

configure(self, cnf=None, **kw) unbound Tkinter.Button method
    Configure resources of a widget.

    The values for resources are specified as keyword
    arguments. To get an overview about
    the allowed keyword arguments call the method keys.


Try it on your own!  As a rule, stay away from methods that start with
an underscore.

André


More information about the Tutor mailing list