[Zope] Re: trying to open a file in database but couldn't

Tres Seaver tseaver at palladion.com
Sun Feb 26 14:16:25 EST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andreas Jung wrote:
> 
> 
> --On 25. Februar 2006 21:55:24 -0800 Allen Huang
> <swapp0 at yahoo.com> wrote:
> 
> 
>>     imageDataFile=StringIO(str(imageData.data))
>>       tfw = open(imageDataFile, "r")
>>
> 
> Please consult the StringIO documentation. There is no need to open()
> a StringIO instance...also your code makes little sense to me because
> str() already returns a string which is usually what you need and want.
> Why do you have the need to put the image data into a StringIO instance.
> And another point: you should always use cStringIO instead of StringIO
> (for performance reasons)...consult the Python Library reference for
> details.
> -aj

In cases where it matters, cStringIO is not Unicode-safe:

  http://www.python.org/doc/current/lib/module-cStringIO.html


Tres.
- --
===================================================================
Tres Seaver          +1 202-558-7113          tseaver at palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEAf6J+gerLs4ltQ4RAuqQAKDD81PwP9o/0kWMyvqOd3MuexIFzgCfduWS
PpS/bwV5AruJwA6pHZFsRA8=
=09y+
-----END PGP SIGNATURE-----



More information about the Zope mailing list