вторник, 14 января 2014 г.

Metaclasses in Python (talk on SF Python)

Interesting talk by Jess Hamrick that helps to put in order knowledge about metaclasses




In questions there was one interesting note about how methods in Python are stored.
So, after instantiating class, every function becomes a method.
Method of class is object (everything is object in Python :) ) that is callable and has special useful attributes (not all listed here):
  • im_func is the function object - it's actually original function
  • im_self is the class instance object
  • im_class is the class of im_self
Obviously, more details can be found in docs http://docs.python.org/2/reference/datamodel.html.
Комментариев нет
Отправить комментарий