Re: NamedTemporaryFile does not match documentation

Discussion in 'Python' started by Jason Friedman, Feb 22, 2013.

  1. > NamedTemporaryFile by default opens a file in binary mode ('w+b'). Write
    > bytes or specify text mode.
    >
    >>>> f.write(b"Hello World!\n")

    > 13
    >>>> ft = NamedTemporaryFile('w+', delete=False)
    >>>> ft.write("Hello World!\n")

    > 13


    Thank you Chris and Serhiy, that helped. I'm inclined to open a
    documentation bug because I could not reproduce the code/output
    snippet on page
    http://docs.python.org/release/3.2.2/library/tempfile.html#module-tempfile.
     
    Jason Friedman, Feb 22, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason Friedman
    Replies:
    0
    Views:
    162
    Jason Friedman
    Feb 21, 2013
  2. Chris Angelico
    Replies:
    0
    Views:
    142
    Chris Angelico
    Feb 21, 2013
  3. Serhiy Storchaka
    Replies:
    0
    Views:
    161
    Serhiy Storchaka
    Feb 21, 2013
  4. Chris Angelico
    Replies:
    0
    Views:
    123
    Chris Angelico
    Feb 22, 2013
  5. Jason Friedman
    Replies:
    0
    Views:
    109
    Jason Friedman
    Feb 22, 2013
Loading...

Share This Page