Okay I understand how to open and read to a file, but how do I write to a 
file, e.g. a list.
----- Original Message ----- 
From: "Nathan Pinno" <[EMAIL PROTECTED]>
To: "Nathan Pinno" <[EMAIL PROTECTED]>; "Danny Yoo" 
<[EMAIL PROTECTED]>
Cc: <tutor@python.org>
Sent: Sunday, July 31, 2005 2:46 PM
Subject: Re: [Tutor] Help with file I/O.


> Here's the improved version.
> file = raw_input("File name please: ")
> f = open(file)
> for line in f.readlines():
>    print line
> f.close()
>
> ----- Original Message ----- 
> From: "Nathan Pinno" <[EMAIL PROTECTED]>
> To: "Danny Yoo" <[EMAIL PROTECTED]>
> Cc: <tutor@python.org>
> Sent: Sunday, July 31, 2005 2:29 PM
> Subject: Re: [Tutor] Help with file I/O.
>
>
>> Here's my work. I call it filewriter.
>> The code:
>> file = raw_input("File name please: ")
>> f = file(file, "r")
>> for line in f.readlines():
>>    print line
>> f.close()
>>
>> Will it do the trick?
>>
>> Nathan
>> ----- Original Message ----- 
>> From: "Danny Yoo" <[EMAIL PROTECTED]>
>> To: "Nathan Pinno" <[EMAIL PROTECTED]>
>> Cc: <tutor@python.org>
>> Sent: Sunday, July 31, 2005 12:22 AM
>> Subject: Re: [Tutor] Help with file I/O.
>>
>>
>>>
>>>
>>> On Sun, 31 Jul 2005, Nathan Pinno wrote:
>>>
>>>> Well, you saw my password program. That was my first attempt at using
>>>> file I/O. Thought I'd try it big time. You saw where that went.
>>>
>>> Ok, let's take a look.  It was from this message, right?
>>>
>>>    http://mail.python.org/pipermail/tutor/2005-July/039478.html
>>>
>>> That was such a while back that I think you probably learned a lot since
>>> then, and I think a few of the issues there were less about I/O and more
>>> about just general programming.
>>>
>>> Let's try a few things, just to see why you're getting stuck.  Can you
>>> write a program that reads in a file, and just prints all of its lines 
>>> out
>>> to screen?
>>>
>>>
>> _______________________________________________
>> Tutor maillist  -  Tutor@python.org
>> http://mail.python.org/mailman/listinfo/tutor
>>
> 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to