Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python for File Systems Manipulation Temporary Files and Directories

Tatiana Vasilevskaya
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tatiana Vasilevskaya
Python Web Development Techdegree Graduate 28,600 Points

Temporary file example from video does work on Mac

If I'm not mistaken, Kenneth meant this code as the example of temporary file handling, which works fine on Mac.

import tempfile

with tempfile.TemporaryFile() as tmpfile:
    tmpfile.write(b"hello\n")
    tmpfile.seek(0)
    tmpfile.read()

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

That's right Tatiana, I spotted that typo too. Kenneth Love accidentally called write on tempfile and not tmpfile. That's the problem with these temporary throw away names!