Skip to content

Instantly share code, notes, and snippets.

@sincerefly
Last active August 29, 2015 14:20
Show Gist options
  • Save sincerefly/4259cdfe73a9043e6256 to your computer and use it in GitHub Desktop.
Save sincerefly/4259cdfe73a9043e6256 to your computer and use it in GitHub Desktop.
python的__builtins__使用,修改了sum函数,使得sum接受sum(1, 2, 3)这样的使用方式
def sum(*args):
return __builtins__.sum(filter(lambda x: type(x) == int, args))
print sum(1, 2, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment