Global variable is undefined at the module level
Peter Otten
__peter__ at web.de
Tue Sep 13 07:39:43 EDT 2016
Daiyue Weng wrote:
> Hi, I defined a global variable in some function like this,
>
> def some_function(self):
>
> global global_var
>
> PyCharm inspection gave me,
>
> Global variable is undefined at the module level
There is no single way to silence that complaint and actually improve your
code; you have to provide some context: Why do you need a global at all, why
can't you (or don't want to) bind it on the module level etc.
More information about the Python-list
mailing list