[Zope] readinf File contents

Chris McDonough chrism@digicool.com
Wed, 5 Jan 2000 13:25:20 -0500


To get the contents of the file object, use its read() method, eg:

a=open("myfile.txt", "rb)
output=a.read()

"output" is now a string you can use re on, etc.

Chris McDonough     mailto:chrism@digicool.com
Digital Creations   http://www.digicool.com
Publishers of Zope  http://www.zope.org

> -----Original Message-----
> From: Michel Pelletier [mailto:michel@digicool.com]
> Sent: Wednesday, January 05, 2000 1:08 PM
> To: 'Richard Smol'; zope@zope.org
> Subject: RE: [Zope] readinf File contents
> 
> 
> > -----Original Message-----
> > From: Richard Smol [mailto:jazzcat@dds.nl]
> > Sent: Wednesday, January 05, 2000 12:38 PM
> > To: zope@zope.org
> > Subject: [Zope] readinf File contents
> > 
> > 
> > Hi there,
> > 
> > This Zope keeps baffling me ... now how do I simply read the 
> > contents of 
> > a File-object?
> 
> fileObject.data or str(fileObject)
> 
> Referencing a file object by name from python will not return it's
> contents, it will return the object.  The object does not, nor should
> it, act or look like a string, which is what re.split expects.
> 
> -Michel
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
>