How to find documentation about methods etc. for iterators

tinnews at isbd.co.uk tinnews at isbd.co.uk
Thu Apr 10 04:24:24 EDT 2008


Terry Reedy <tjreedy at udel.edu> wrote:
> 
> <tinnews at isbd.co.uk> wrote in message 
> news:47fce941$0$755$bed64819 at news.gradwell.net...
> | I'm not sure if I have even phrased that right but anyway....
> |
> | How does one find (in the standard Python documentation) information
> | about things like the iteritems() method and the enumerate() function.
> 
> The Library Reference manual sections on builtin functions and dict 
> methods.
> 
> Or, help(enumerate) and help({}.iteritems)
> 
.... but that doesn't address my problem really, how do I know that I
need to look for the words enumerate and/or iteritems?  This is what
my original question was about.

There I was thinking that there has to be an easy way to get line
numbers as I read lines from a file but not knowing how to find out
how to do it:-

    First question, what sort of 'thing' is the file object, I need to
    know that if I'm to look up ways of using it.

    Second question, even if I know what sort of thing a file object
    is, how do I find methods applicable to it and/or functions
    applicable to it?

The possibility that I might want either a method or a function adds
to the fun.  In my original query it seemed odd that some objects have
the iteritems *method* whereas other objects have the enumerate
*function*.

It's a common problem in all sorts of computer fields, if you know the
name of what you want it's easy to find out details of how to use it
but if you don't know its name (or even if it exists) it's much more
difficult to find.

I've only been using Python for a few months and most of the time I
can find my way to what I need but this area of "what things can I do
with this object" still eludes me sometimes.  What *I* need (I'm not
sure if this is a universal requirement though) is some consistent way
of firstly finding out what sort of an object something is (i.e. in
this case, what sort of object is a file) and then getting a list of
methods that I can apply to that object (O.K., this may need some
hierachy or other classification to keep it sane, but hopefully you
can see where I'm going).

-- 
Chris Green



More information about the Python-list mailing list