Python's equivalent for Ruby's define_method?

后端 未结 4 2030
傲寒
傲寒 2021-01-06 10:57

Is there a Python equivalent for Ruby\'s define_method, which would allow dynamic generation of class methods? (as can be seen in Wikipedia\'s Ruby example code

4条回答
  •  情书的邮戳
    2021-01-06 11:28

    Either look into abstract base classes:

    http://docs.python.org/library/abc.html

    or

    check the options that the 'new' (or the newer 'types') module provides to you.

提交回复
热议问题