Skip to content

Conversation

@TakesxiSximada
Copy link
Contributor

I seems that the bsObj class variable has got promoted to a global variable, when interpreter processed the global keyword.

@TakesxiSximada
Copy link
Contributor Author

For example, the following code class variable b was promoted to global.

test.py:

class A:
    b = None
    def test(self):
        global b
        b = 1
A().test()
print(b)

Run test.py

$ python test.py 
1

@REMitchell
Copy link
Owner

Can I get more clarification on why you think using the global keyword is a bad thing here?

@TakesxiSximada
Copy link
Contributor Author

A.b of the above example is not used. A.b remains None.
A.b and TestWikipedia.bsObj is the same.

TestWikipedia.bsObj is not used. Global bsObj is used.
TestWikipedia.bsObj and global bsOb are not the same object.

I think also that there is no need to be as my fix, but I think that not the intended behavior.

Please forgive me my lousy English. thanks.

@REMitchell
Copy link
Owner

Wouldn't removing
bsObj = None
url = None

have the same effect and require fewer changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants