encapsulating a global variable

Chris Angelico rosuav at gmail.com
Tue Feb 25 07:56:27 EST 2020


On Tue, Feb 25, 2020 at 11:41 PM BlindAnagram <blindanagram at nowhere.com> wrote:
>
> I would appreciate advice on whether it is possible to avoid the use of
> a global variable used in a function by encapsulating it in a class
> without maaking any changes to the call interface (which I cannot change).

Why bother? If you aren't changing where the function's called, then
its state is effectively global anyway, so what's the point of the
class?

ChrisA


More information about the Python-list mailing list