Text processing and file creation

Steve Holden steve at holdenweb.com
Wed Sep 5 19:46:21 EDT 2007


Arnaud Delobelle wrote:
[...]
> from my_useful_functions import new_file, write_first_5_lines,
> done_processing_file, grab_next_5_lines, another_new_file, write_these
> 
> in_f = open('myfile')
> out_f = new_file()
> write_first_5_lines(in_f, out_f) # write first 5 lines
> close(out_f)
> while not done_processing_file(in_f): # until done processing
>    lines = grab_next_5_lines(in_f) # grab next 5 lines
>    out_f = another_new_file()
>    write_these(lines, out_f) # write these
>    close(out_f)
> print "all done!" # All done
> print "Now there are 4000 files in this directory..."
> 
> Python 3.0 - ready (I've used open() instead of file())
> 
bzzzzzzzzzzt!

Python 3.0a1 (py3k:57844, Aug 31 2007, 16:54:27) ...
Type "help", "copyright", "credits" or "license" for more information.
 >>> print "all done!" # All done
   File "<stdin>", line 1
     print "all done!" # All done
                     ^
SyntaxError: invalid syntax
 >>>

Close, but no cigar ;-)

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list