Global variable is undefined at the module level
Ned Batchelder
ned at nedbatchelder.com
Tue Sep 13 07:47:29 EDT 2016
On Tuesday, September 13, 2016 at 6:42:56 AM UTC-4, 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
>
> How to fix this?
It probably wants you to have a line at the top-level of the module (outside of any function) defining the variable:
global_var = None # or some other default value
--Ned.
More information about the Python-list
mailing list