Extension methods in Python

后端 未结 6 977
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 01:55

Does Python have extension methods like C#? Is it possible to call a method like:

MyRandomMethod()

on existing types like int?

6条回答
  •  梦谈多话
    2021-01-31 02:28

    I've had great luck with the method described here:

    http://mail.python.org/pipermail/python-dev/2008-January/076194.html

    I have no idea if it works on builtins though.

提交回复
热议问题