Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: NamedTemporaryFile does not match documentation (http://www.velocityreviews.com/forums/t957902-re-namedtemporaryfile-does-not-match-documentation.html)

Chris Angelico 02-21-2013 08:54 PM

Re: NamedTemporaryFile does not match documentation
 
On Fri, Feb 22, 2013 at 7:46 AM, Jason Friedman <jsf80238@gmail.com> wrote:
> Python 3.2.2 (default, Feb 14 2012, 08:06:31)
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-50)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from tempfile import NamedTemporaryFile
>>>> f = NamedTemporaryFile(delete=False)


The default 'mode' is 'w+b', meaning that you need to send it binary,
not Unicode strings. Try adding mode='w+' to the constructor, and
possibly also an encoding= argument.

ChrisA


All times are GMT. The time now is 05:30 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.