On Fri, Aug 23, 2019 at 4:00 AM Windson Yang <wiwind...@gmail.com> wrote: > > Thank you all. I agreed with Frank that > > > It would make sense to use the 'global' keyword if you have a module > with various functions, several of which refer to 'foo', but only one of > which changes the value of 'foo'. > > I also found an example in cpython/lib/gettext.py, only 'textdomain > function' can change '_current_domain', other functions just refer to it. > So, it will be not evil or to use 'global' keyword correctly when there is > only one function can change its value? > > Cameron Simpson <c...@cskk.id.au> 于2019年8月23日周五 下午3:15写道: >
The problem with deciding that only one function can change the value, is that someone else can change the other functions. So, if you are working alone, it won't be a problem, but once code with globals enters the 'wild' all bets are off. -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list