list to string

David LeBlanc whisper at oz.net
Tue Jul 23 20:50:42 EDT 2002


To all who replied - many thanks!

Skip surmized correctly that I just wanted a big string (with embedded
newlines) instead of the list of lists that readlines() returns.

Regards,

David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Skip Montanaro
> Sent: Tuesday, July 23, 2002 15:00
> To: David LeBlanc
> Cc: Python-List at Python. Org
> Subject: Re: list to string
>
>
>
>     David> fn = file('foo.txt')
>     David> txt = fn.readlines()
>     David> str = ?something?(txt) # or txt.?something?()...
>
> Assuming what you really want is to get the contents of the file in one
> gulp, this should work:
>
>     fn = file('foo.txt')
>     str = fn.read()
>
> --
> Skip Montanaro
> skip at pobox.com
> consulting: http://manatee.mojam.com/~skip/resume.html
>
> --
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list