global
statement detected PYL-W0603185 to each row.
186 Inspired by https://stackoverflow.com/a/53118102.
187 """
188 global prev_line_num189 if row["word_num"] == 1:
190 current_line_num = prev_line_num # noqa: F841
191 prev_line_num += 1
284
285
286def main_worker(gpu, ngpus_per_node, args, writer=None):
287 global best_acc1288 args.gpu = gpu
289
290 if args.gpu is not None:
It is recommended not to use global
statement unless it is really necessary. Global variables are dangerous because they can be simultaneously accessed from multiple sections of a program. This frequently results in bugs. This also make code difficult to read, because they force you to search through multiple functions or even modules just to understand all the different locations where the global variable is used and modified. Read more about why it should be avoided here.