Comment

Comment by sebleblanc

And if you want to emulate static variables in a function, you can do that:

    def counter():
        counter.x += 1
        return counter.x

    counter.x = 0
    counter()
    > 1
    counter()
    > 2
Beware! singleton variables, mutable state, etc.
parent sebleblanc 11 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton