@lclarkejhdf/

Problem with getters

Python

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.27642729459216975","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"Y2xhc3MgdGVzdDoKICBkZWYgX19pbml0X18oc2VsZiwgYXR0cik6CiAgICBzZWxmLmF0dHIgPSBhdHRyCiAgCiAgZGVmIGdldEF0dHIoc2VsZik6CiAgICByZXR1cm4gc2VsZi5hdHRyCiAgCiAgZGVmIHNldEF0dHIoc2VsZiwgbmV3QXR0cik6CiAgICBzZWxmLmF0dHIgPSBuZXdBdHRyCgp0MSA9IHRlc3QoWzEsMiwzXSkKCmxzdCA9IHQxLmdldEF0dHIoKQpwcmludCgiTGlzdCAxOiIsbHN0KQpsc3QuYXBwZW5kKDQpCnByaW50KCJMaXN0IDI6Iixsc3QpCmxzdCA9IFtdCm5ld2xzdCA9IHQxLmdldEF0dHIoKQpwcmludCgiTGlzdCAzOiIsbmV3bHN0KQpwcmludCgiXG5MaXN0IDMgc2hvdWxkIGJlIGp1c3QgWzEsMiwzXSwgYnV0IHRoZSBhcHBlbmQgcGVyZm9ybWVkIG9uIHRoZSB2YXJpYWJsZSBoYXMgYmVlbiBwZXJmb3JtZWQgb24gdGhlIGF0dHJpYnV0ZS4iKQ=="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class test:
  def __init__(self, attr):
    self.attr = attr
  
  def getAttr(self):
    return self.attr
  
  def setAttr(self, newAttr):
    self.attr = newAttr

t1 = test([1,2,3])

lst = t1.getAttr()
print("List 1:",lst)
lst.append(4)
print("List 2:",lst)
lst = []
newlst = t1.getAttr()
print("List 3:",newlst)
print("\nList 3 should be just [1,2,3], but the append performed on the variable has been performed on the attribute.")