static variables
Marko Rauhamaa
marko at pacujo.net
Wed Dec 2 06:30:31 EST 2015
Antoon Pardon <antoon.pardon at rece.vub.ac.be>:
> Op 02-12-15 om 11:18 schreef Marko Rauhamaa:
>> I don't know why global accessibility is such a problem.
>
> Some people seem to have a problem with global variables.
Well, *I* don't go around defining global variables, but there are times
when they are the way to go. For example, if a module function uses a
regular expression, the regular expression should be compiled into a
(module) global variable.
Module functions and classes are global variables as well:
>>> import math
>>> def f(x): return -1
...
>>> math.sqrt = f
>>> math.sqrt(3)
-1
Marko
More information about the Python-list
mailing list