Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: