mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 20:50:14 +01:00
py: Add setattr builtin.
This commit is contained in:
13
tests/basics/setattr1.py
Normal file
13
tests/basics/setattr1.py
Normal file
@@ -0,0 +1,13 @@
|
||||
class A:
|
||||
|
||||
var = 132
|
||||
|
||||
def __init__(self):
|
||||
self.var2 = 34
|
||||
|
||||
|
||||
a = A()
|
||||
setattr(a, "var", 123)
|
||||
setattr(a, "var2", 56)
|
||||
print(a.var)
|
||||
print(a.var2)
|
||||
Reference in New Issue
Block a user