April 29, 2020 / Viewed: 333 / Comments: 0 / Edit
Example of how to create a global variable in python:
Table of Contents
To declare for example a as a global variable:
global a
Using global variables in a function:
>>> global a,b
>>> a = 0.5
>>> b = 2
>>> def function( x ):
... return a * x + b
...
>>> function(1)
2.5
>>> b = 4
>>> function(1)
4.5
Je développe le présent site avec le framework python Django. Je m'intéresse aussi actuellement dans le cadre de mon travail au machine learning pour plusieurs projets (voir par exemple) et toutes suggestions ou commentaires sont les bienvenus !