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

Keith Dart kdart at kdart.com
Sun Dec 19 22:51:29 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
> 

I don't think so. But in the pyNMS package 
(http://sourceforge/net/projects/pynms) there is a module called 
"expect", and a class "Expect". With that you can wrap a file object and 
use the Expect.read_until() method to do what you want.



-- 
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Keith Dart <kdart at kdart.com>
    public key: ID: F3D288E4
    =====================================================================



More information about the Python-list mailing list