# Intercepting class method invocations using metaclass programming in Python

DevFeed: [Intercepting class method invocations using metaclass programming in Python](<https://devfeed.tech/articles/intercepting-class-method-invocations-using-metaclass-programming-in-python-20740.md>)

Original publisher: [Read original article](<https://blog.fedecarg.com/2018/10/08/intercepting-class-method-invocations-using-metaclass-programming-in-python/>)

Author: Federico

Published: 2018-10-08T19:52:00Z

Content type: tutorial

Language: en

Sources: [Federico Cargnelutti](<https://devfeed.tech/sources/federico-cargnelutti.md>)

Topics: [Python](<https://devfeed.tech/topics/python.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>)

Tags: [class](<https://devfeed.tech/tags/class.md>), [examples](<https://devfeed.tech/tags/examples.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [implement](<https://devfeed.tech/tags/implement.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

## AI overview

A Python tutorial explains how metaclass programming can intercept class method invocations, comparing the approach with Ruby's method_missing and Python's __getattr__. It also notes that Python treats methods as properties rather than distinguishing them as Ruby does.

## Source excerpt

In Ruby, objects have a handy method called method_missing which allows one to handle method calls for methods that have not been defined. Most examples out there explain how to implement this in Python using __getattr__, however, none of them (honestly, none) explain how to intercept class method (@classmethod) invocations using __metaclass__. And this is [...]