3 ms·
You don't necessarily have to mark it as global to mutate. Some more interesting behavior: class BoxedInt(object): def __init__(self, v):
by yummyfajitas 15y ago
You don't necessarily have to mark it as global to mutate. Some more interesting behavior:
class BoxedInt(object):
def __init__(self, v):
self.val = v
x = BoxedInt(0)
def foo():
x.val = x.val + 1
print x.val