Skip to content

Instantly share code, notes, and snippets.

@Alwinfy
Created February 8, 2024 02:10
Show Gist options
  • Save Alwinfy/f445c666651c8c21f097382b3fbb7987 to your computer and use it in GitHub Desktop.
Save Alwinfy/f445c666651c8c21f097382b3fbb7987 to your computer and use it in GitHub Desktop.
def modifyat(ls, ix, fn):
return ls[:ix] + (fn(ls[ix]),) + ls[ix + 1:]
def global_counter():
code = global_counter.__code__
global_counter.__code__ = code.replace(co_consts = modifyat(code.co_consts, len(code.co_consts) - 1, (1).__add__))
return 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment