T
tinnews
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.
They are mentioned in the tutorial as ways of getting more information
as you loop through an object but there seems to be no easy way to
find the definitive documentation of these sorts of methods and
functions. OK, if I know the name before I start I can probably find
what I want, but what if I want to know how to extract some
information from an object as I loop and don't know what I want is
called?
My particular quest that raised this was a way to get the line number
as I iterate through the lines of a file:-
f = open(fn, 'r')
lineNo = 0
for ln in f:
lineNo += 1
Is there a neater way of getting that line number as I go? If so how
am I meant to find out about it?
How does one find (in the standard Python documentation) information
about things like the iteritems() method and the enumerate() function.
They are mentioned in the tutorial as ways of getting more information
as you loop through an object but there seems to be no easy way to
find the definitive documentation of these sorts of methods and
functions. OK, if I know the name before I start I can probably find
what I want, but what if I want to know how to extract some
information from an object as I loop and don't know what I want is
called?
My particular quest that raised this was a way to get the line number
as I iterate through the lines of a file:-
f = open(fn, 'r')
lineNo = 0
for ln in f:
lineNo += 1
Is there a neater way of getting that line number as I go? If so how
am I meant to find out about it?