Hi folks,
Is it possible to add class methods to a class using Categories?
when I try what appears to me to be the naive way to do it:
from objc import Category from AppKit import NSImage
class NSImage(Category(NSImage)):
def read_(cls, filepath): return NSImage.alloc().initWithhContentsOfFile_(filepath) read_ = classmethod(read_)
when I try to call NSImage.read_('/path/to/my/file'), I get:
TypeError: Expecting instance of NSImage as self, got one of str
Incidentally, is classmethod the proper way to make class methods for PyObjC classes?
--Dethe
"...our universities, I suggest, are not half-way out of the fifteenth
century. [...] The three or four years' course of lectures, the bachelor
who knows some, the master who knows most, the doctor who knows all, are ideas that have come down unimpaired from the Middle Ages. Nowadays no one should end his learning while he lives and these university degrees are preposterous. [...] Educationally we are still for all practical purposes in the coach and horse and galley stage." H. G. Wells
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig