[Tutor] a quick Q: how to use for loop to read a series of files with .doc end
Walter Prins
wprins at gmail.com
Thu Sep 29 17:57:15 CEST 2011
Hi,
On 29 September 2011 16:39, lina <lina.lastname at gmail.com> wrote:
>
> Or you can get lines 24-28, with text[24, 29] (look up slices in the
>> Python doc)
>>
>
Dave probably meant: text[24:29]
> >>> print splitext.__doc__
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'splitext' is not defined
> >>> print slices.__doc__
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'slices' is not defined
> >>> print slices._doc_
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> NameError: name 'slices' is not defined
>
You should probably be looking in the documentation, not trying to feed it
into the interpreter. (If you want to get help on a specific entity in
Python it's usually better to use the "help()" function, e.g:
>>> import os.path
>>> help (os.path.splitext)
Help on function splitext in module ntpath:
splitext(p)
Split the extension from a pathname.
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty.
>>>
Note, trying to do "help(os.path.splitext)" would not have worked before I
imported the "os.path" module. (Differently put: Whatever you want to get
help() on, must be known to the interpreter, so must either be built in or
previously imported.)
Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110929/26f0a183/attachment.html>
More information about the Tutor
mailing list