>>> class foo():... bar = 1... >>> foo.bar1>>> foo.__dict__['bar']1
>>> class foo():
... bar = 1
...
>>> foo.bar
1
>>> foo.__dict__['bar']
References :
dynamic - python: How to add property to a class dynamically? - Stack Overflow
沒有留言:
張貼留言