input record seperator (equivalent of "$|" of perl)

Doug Holton insert at spam.here
Mon Dec 20 00:39:31 CET 2004


les_ander at yahoo.com wrote:

> Hi,
> I know that i can do readline() from a file object.
> However, how can I read till a specific seperator?
> for exmple,
> if my files are
> 
> name
> profession
> id
> #
> name2
> profession3
> id2
> 
> I would like to read this file as a record.
> I can do this in perl by defining a record seperator;
> is there an equivalent in python? 
> thanks
> 

To actually answer your question, there is no equivalent to $| in python.

You need to hand code your own record parser, or else read in the whole 
contents of the file and use the string split method to chop it up into 
fields.



More information about the Python-list mailing list