Skip to content

Instantly share code, notes, and snippets.

@ruoyu0088
Created October 11, 2016 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruoyu0088/d385f3ca04583c481538751f50adc364 to your computer and use it in GitHub Desktop.
Save ruoyu0088/d385f3ca04583c481538751f50adc364 to your computer and use it in GitHub Desktop.
import gc
def set_class_dict(klass, key, value):
import gc
d = gc.get_referents(klass.__dict__)[0]
d[key] = value
set_class_dict(str, "toint", lambda self:int(self))
print("123".toint())
@laowu2019
Copy link

如何传递参数呢? 比如我想把 center 函数变成 "居中", 该怎么做呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment