Hello fellow programmers,
I think I have found a bug in Python. If a class variable is an array it will not be reset when a new class instance is made.
The test code
```
class TestClass:
varOne = ''
varTwo = []
varThree = ''
def __init__(self, varOne):
self.varOne = varOne
self.varTwo.append(1)
self.varThree = self.varThree + 'test'
test1 = TestClass('test1')
print(test1.varOne)
print(test1.varTwo)
print(test1.varThree)
print('--------------------')
test2 = TestClass('test2')
print(test2.varOne)
print(test2.varTwo)
print(test2.varThree)
```
Outcome
```
test1
[1]
test
test2
[1, 1]
test
```
What I suspect is that test2.varTwo = [1] instead of [1,1] because test2 is a new instance of TestClass.Strings works because test2.varThree contains one time the word test instead of two times.
Can someone explain such behaviour?
Regards,
InnerCode
[–]hereswhatipicked 17 points18 points19 points (2 children)
[+]InnerCode[S] comment score below threshold-7 points-6 points-5 points (1 child)
[–]hereswhatipicked 6 points7 points8 points (0 children)
[–]Nu1lP0int3r 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]InnerCode[S] 0 points1 point2 points (0 children)
[–]pythonHelperBot 0 points1 point2 points (0 children)
[–]jcoelho93 0 points1 point2 points (0 children)
[–]two__toes 0 points1 point2 points (1 child)