MethodViewのコードを読んでたら、例としてわかりやすかったのでメモ。どういう動きをするのかはあらかじめ「Pythonのメタプログラミング (メタクラス) を理解したい人のための短いコード片と禅問答」を読んでおくと良いと思う。 class MethodViewType(type): def __new__(cls, name, bases, d): rv = type.__new__(cls, name, bases, d) if 'methods' not in d: methods = set(rv.methods or []) for key in d: if key in http_method_funcs: methods.add(key.upper()) if methods: rv.methods = sorted(methods) return rv class Me
![FlaskのViewのメタプログラミングの例がわかりやすかった。](https://cdn-ak-scissors.b.st-hatena.com/image/square/e3356803e0ca2fbf81750674b5e9ef63e7a486bc/height=288;version=1;width=512/http%3A%2F%2Fwww.kzfmix.com%2Fimages%2Fogp%2Fogp_logo.jpg)