This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: global var defined in module not returned by function
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: arthur, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2015-07-08 16:03 by arthur, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg246460 - (view) Author: (arthur) Date: 2015-07-08 16:03
defined global var, glob.myVar, in separated module
imported module containing glob.myVar

in function1, func1():
glob.myVar = ""
func1Var = func2()

in function2, func2():
if (...):
glob.myVar+= "abc" 
func2() # call func2() again - recursive
else:
return glob.myVar

I always find:
func1Var is None = True

An obvious workaround is
func1Var = glob.myVar
which is fine
msg246461 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2015-07-08 16:07
You should start by posting this to python-list or StackOverflow, and I'd suggest including code that can actually be run - it's far more precise than pseudocode.

(Functions and modules get used a lot. It's far more likely there's a bug in your code than in Python's implementation.)
History
Date User Action Args
2022-04-11 14:58:18adminsetgithub: 68780
2015-07-08 16:07:55steve.dowersetstatus: open -> closed
resolution: not a bug
messages: + msg246461

stage: resolved
2015-07-08 16:03:01arthurcreate