[issue8890] Use tempfile instead of /tmp in examples

Mauro Navarro Baraldi report at bugs.python.org
Sun Nov 21 19:23:27 CET 2010


Mauro Navarro Baraldi <mauro.baraldi at gmail.com> added the comment:

Reviewing this thread and talking with another friends, I thought that the pythonic way to solve it should be use the tempfile module.

And here is a suggestion using the logging module with tempfile.

> import logging
> import tempfile
> fp, LOG_FILENAME = tempfile.mkstemp(suffix=".log")
> logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG)
> logging.debug('This message should go to the log file')
> LOG_FILENAME
'/tmp/tmprBhZz1.log'

----------
components: +Demos and Tools -Documentation

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8890>
_______________________________________


More information about the Python-bugs-list mailing list