Skip to content

Files

Latest commit

 

History

History
30 lines (19 loc) · 549 Bytes

global-at-module-level.md

File metadata and controls

30 lines (19 loc) · 549 Bytes

Pattern: Unnecessary global statement at module level

Issue: -

Description

Using global makes sense only within nested scopes of a given module. It has no effect if used at the module level.

Example of incorrect code:

global name
name = "test"

def func():
    global name

Example of correct code:

def func():
    global name
    name = "test"

Further Reading