Re: [Tutor] Reading a file

2010-07-02 Thread Alan Gauld
"David Hutto" wrote In the code below, I'm trying to read from a file, and print out the lines. Steven addressed that but... def increment(): for number in range(1, 500): print number ++1 This function if called will print out all of the numbers at once, it won't return an

Re: [Tutor] Reading a file

2010-07-02 Thread David Hutto
On Fri, Jul 2, 2010 at 11:31 AM, Steven D'Aprano wrote: > On Fri, 2 Jul 2010 11:16:02 pm David Hutto wrote: >> In the code below, I'm trying to read from a file, and print out the >> lines. > > f = open("filename.txt") > for line in f: >    print line > f.close() > > is all you need, and even the

Re: [Tutor] Reading a file

2010-07-02 Thread Steven D'Aprano
On Fri, 2 Jul 2010 11:16:02 pm David Hutto wrote: > In the code below, I'm trying to read from a file, and print out the > lines. f = open("filename.txt") for line in f: print line f.close() is all you need, and even the close at the end is optional (but recommended). > I know I've seen t

[Tutor] Reading a file

2010-07-02 Thread David Hutto
In the code below, I'm trying to read from a file, and print out the lines. I know I've seen the exact function I'm looking for here, but it seems like the below 'should' work. The second function(rdfil) works, if just the line number is placed there, and th first(increment) works for printing a n

[Tutor] Reading a file and best approach for it...

2009-04-10 Thread Spencer Parker
I have a flat file database that I want to get information from. The basic text looks like this: ITEM{ "FULLNAME" "apps114.chgit.com!file:/etc" "RECOVERY" "0" } They are all on a separate line in the text file. I had thought about trying to drop it into a list or a