开发者

Can the python image module be extended?

Can the python Image module be extended ? Basically its a class I think and I want to have added a numpy array representation of the image.

If I 开发者_开发问答know how to extend it, then I can add all other extensions I wish to add to it too I think, but I don't know how to build up on existing classes.


You "extend" classes by subclassing them, as in

class MiniMath:
    def add(self, a, b):
        return a + b

class MoreMath(MiniMath):
    def sub(self, a, b):
        return a - b

mm = MoreMath()
print mm.add(1, 2) # 3
print mm.sub(1, 2) # -1

I suggest you read the Python tutorial first though.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜