[Tutor] Reading Program

bob gailer bgailer at gmail.com
Wed Apr 10 16:31:26 CEST 2013


On 4/8/2013 2:58 PM, Donald Dietrich wrote:
> I am just new to python programing, but would like some help 
> developing a program for "flow reading"  What I would like the program 
> to do is use any  .txt file like micorsoft word .txt file and flow the 
> words across the screen one at time until the file is come to the end. 
> I would also like to control the rate (time) of flow. Do you think you 
> can help me.
To Tutors:

I had a phone chat with Donald yesterday. Summary:
Win 8, IDLE, Python 3.1.

Working his way thru Python for Absolute Beginner.

He is seeking other books as well.

To Donald:

Here's the easiest way to create a text file:

In IDLE: File -> New Window
Enter 2 lines with 2 words on each line.
File -> Save:
   File name: test1.txt
   Save as type: Text files (*.txt)

Here's an interactive session showing some ideas:

In the Python Shell (read a file)
 >>> txt = open("test1.txt")
 >>> print(txt.read())
you should see the file contents here

In the Python Shell (parse the file into words)
 >>> txt = open("test1.txt")
 >>> print(txt.read().split())
you should see a list of the words in the file

In the Python Shell (display the words with a time delay)
 >>> txt = open("test1.txt")
 >>> for word in txt.read().split():
     print(word)
     time.sleep(.4)
now press enter again and you should see the words appear with a 0.4 
second delay.

Hope this helps get you going. Feel free to come back with questions.


-- 
Bob Gailer
919-636-4239
Chapel Hill NC

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130410/5e1140b1/attachment.html>


More information about the Tutor mailing list