[Tutor] Suggestions as to how to read a file in paragraphs

Kent Johnson kent_johnson at skillsoft.com
Thu Sep 2 11:50:45 CEST 2004


I took a look at the source code for reading lines from a file (in 
Objects/fileobject.c/get_line()). The three recognized line endings are 
hard-coded (the code looks specifically for \r, \n and \r\n) so you can't 
customize this.

Kent

At 11:31 PM 9/1/2004 -0700, Danny Yoo wrote:
> > I know in perl there is an input record separator which by default is
> > the newline and one can specify this to a specific delimiter. Is there
> > one in python?
>
>Not certain.  Python has adopted 'universal newlines' support,
>
>     http://www.python.org/doc/2.3.4/whatsnew/node7.html
>
>This allows us to tell Python to guess between the three main standard
>ways to define a line.  So there may be something in Python that we might
>be able to reuse, to redefine a "line" as something else.  But I'm not
>sure how easily accessible this might be.
>
>
>Good luck to you!
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list