recursive function: use a global or pass a parameter?
Roy Smith
roy at panix.com
Sat Jan 17 10:20:03 EST 2015
In article <54ba3654$0$13008$c3e8da3$5496439d at news.astraweb.com>,
Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> Good reasons for using global variables are few and far between. Just about
> the only good reason for using global variables that I can think of is if
> you have one or more settings/preference that get set once at the start of
> the program and then apply to the entire program.
I will commonly put something like:
import logging
logger = logging.getLogger("logger-name-for-my-module")
in every source file in a big project. Now I've got a global logger I
can use anywhere in the module (even in static functions). But, maybe
that's just a subset of your "setting that gets set once at the start of
the program" example.
More information about the Python-list
mailing list