[docs] [issue8890] Use tempfile instead of /tmp in examples

engelbert gruber report at bugs.python.org
Sun Jun 26 16:51:19 CEST 2011


engelbert gruber <grubert at users.sourceforge.net> added the comment:

Assumption:

  /tmp is used in examples so the examples work 
  because /tmp is always writeable

module tempfile is for creating temporary files, the name of which is unimported, when a user is trying code from documentation it might be hard on him/her to additionally guess/save the random filenames.

``grep tmp -r CPython3.3/Doc`` (trimmed results and grouped)

* Doc/distutils/install.rst, Doc/install/install.rst:

  e.g. ``--install-base=/tmp`` 

  maybe ``--install-base=<other-python-base-directory>``
  if someone installs to another directory, one has a reason and 
  therefore knows the directory.

* all other e.g. ::

    Doc/library/sqlite3.rst::file:`/tmp/example` file::
    Doc/library/sqlite3.rst:   conn = sqlite3.connect('/tmp/example')

  use ``/tmp`` because it is writeable, but assuming the user wants
  to program i think it is not so big a burden to assume him/her to
  grasp the concept of directories, files and write protection.

  So either it can be left out, as in sqlite3.rst, maybe a file 
  extension would be more helpful, or replaced by a placeholder
  like ``<my-log-directory>`` or ``<directory-for-tempfiles>``.

  I am unsure about the ``<>`` chars ?

list of files:

Doc/distutils/install.rst
Doc/documenting/fromlatex.rst
Doc/howto/logging-cookbook.rst
Doc/install/install.rst
Doc/library/atexit.rst
Doc/library/cgi.rst
Doc/library/imghdr.rst
Doc/library/mailcap.rst
Doc/library/nntplib.rst
Doc/library/optparse.rst
Doc/library/packaging.database.rst
Doc/library/packaging.pypi.simple.rst
Doc/library/pipes.rst
Doc/library/sqlite3.rst
Doc/library/tempfile.rst
Doc/library/trace.rst
Doc/library/zipimport.rst
Doc/tools/sphinxext/susp-ignored.csv
Doc/tutorial/inputoutput.rst

So which way ?

----------
nosy: +grubert

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


More information about the docs mailing list