Module biogeme.filenames

Examples of use of each function

This webpage is 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. For examples of models, visit biogeme.epfl.ch.

In [1]:
import datetime
print(datetime.datetime.now())
2020-06-03 10:01:04.602020
In [2]:
import biogeme.version as ver
print(ver.getText())
biogeme 3.2.6 [2020-06-03]
Version entirely written in Python
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)

In [3]:
import biogeme.filenames as fl

The role of this function is to obtain the name of a file that does not exist.

In [4]:
theName = fl.getNewFileName('test', 'dat')
theName
Out[4]:
'test~07.dat'

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.

In [5]:
open(theName, 'a').close()
In [6]:
theName = fl.getNewFileName('test', 'dat')
theName
Out[6]:
'test~08.dat'

If we do it again, the number is incremented.

In [7]:
open(theName, 'a').close()
In [8]:
theName = fl.getNewFileName('test', 'dat')
theName
Out[8]:
'test~09.dat'
In [ ]: