Set a flag on the function or a global?

Ethan Furman ethan at stoneleaf.us
Tue Jun 16 10:57:07 EDT 2015


On 06/16/2015 06:56 AM, Michael Torrie wrote:
> On 06/15/2015 06:19 PM, Ethan Furman wrote:
>>
>> Setting a global on the module (which I may not have, and probably
>> didn't, import) for only one function is overkill.
>
> What do you mean?  Even if you pull in just one function from the
> module on an import, the module's initialization code still runs.

For me, an appropriate use of globals requires that it will be used by many other pieces of code in that module.  If only one piece of code is using it, it's not really global.

--
~Ethan~



More information about the Python-list mailing list