[Pythonmac-SIG] Categories for class methods
Bob Ippolito
bob at redivi.com
Thu Jan 27 21:57:00 CET 2005
On Jan 27, 2005, at 15:24, Dethe Elza wrote:
> FYI, once I updated PyObjC from svn, my example code worked, thanks
> again Ronald.
...
> class NSImage(Category(NSImage)):
>
> def rect(self):
> return (0,0),self.size()
>
> @classmethod # for Python2.3 replace with read_ =
> classmethod(read_)
> def read_(cls, filepath):
> return NSImage.alloc().initWithContentsOfFile_(filepath)
Just a nit here, you should probably call this imageWithFilePath_ to
follow convention. "read:" is a really confusing name for an
initializer.
-bob
More information about the Pythonmac-SIG
mailing list