.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/programmers/plot_filenames.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_programmers_plot_filenames.py: biogeme.filenames ================= Examples of use of several functions. This is designed for programmers who need examples of use of the functions of the module. The examples are designed to illustrate the syntax. They do not correspond to any meaningful model. :author: Michel Bierlaire :date: Wed Nov 22 13:47:01 2023 .. GENERATED FROM PYTHON SOURCE LINES 17-20 .. code-block:: default import biogeme.version as ver import biogeme.filenames as fl .. GENERATED FROM PYTHON SOURCE LINES 21-22 Version of Biogeme. .. GENERATED FROM PYTHON SOURCE LINES 22-24 .. code-block:: default print(ver.getText()) .. rst-class:: sphx-glr-script-out .. code-block:: none biogeme 3.2.13 [2023-12-23] Home page: http://biogeme.epfl.ch Submit questions to https://groups.google.com/d/forum/biogeme Michel Bierlaire, Transport and Mobility Laboratory, Ecole Polytechnique Fédérale de Lausanne (EPFL) .. GENERATED FROM PYTHON SOURCE LINES 25-26 The role of this function is to obtain the name of a file that does not exist. .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: default the_name = fl.get_new_file_name('test', 'dat') the_name .. rst-class:: sphx-glr-script-out .. code-block:: none 'test.dat' .. GENERATED FROM PYTHON SOURCE LINES 30-33 Now, let's create that file, and call the function again. A suffix with a number is appended to the name of the file, before its extension. .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: default open(the_name, 'a').close() .. GENERATED FROM PYTHON SOURCE LINES 36-39 .. code-block:: default the_name = fl.get_new_file_name('test', 'dat') the_name .. rst-class:: sphx-glr-script-out .. code-block:: none 'test~00.dat' .. GENERATED FROM PYTHON SOURCE LINES 40-41 If we do it again, the number is incremented. .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: default open(the_name, 'a').close() .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: default the_name = fl.get_new_file_name('test', 'dat') the_name .. rst-class:: sphx-glr-script-out .. code-block:: none 'test~01.dat' .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.002 seconds) .. _sphx_glr_download_auto_examples_programmers_plot_filenames.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_filenames.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_filenames.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_