On Thu, Jun 19, 2008 at 2:44 AM, John [H2O] <[EMAIL PROTECTED]> wrote:
>
> I've defined:
>
> def get_contents(infile=file_object):
>   """ return a list of lines from a file """
>   contents=infile.read()
>   contents = contents.strip().split('\n')
>   return contents

> I think I understand the differences, but can someone tell me if there's any
> difference between what I define and the readlines() method?

readline() and readlines() include the trailing newline in the lines
they return; your function does not.
readline() and readlines() don't strip leading and trailing space.

contents = contents.splitlines(True) would duplicate readlines() I think.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to