[Image-SIG] how to subclass Image?

William Henney whenney at gmail.com
Wed Mar 29 17:20:01 CEST 2006


"Fredrik Lundh" <fredrik at pythonware.com> writes:

> William Henney wrote:
>
>> I was wondering how one should best go about subclassing PIL's image
>> class. This does not seem as straightforward as I thought it was going
>> to be.
>
> the Image class isn't designed to be subclassed by application code.  if
> you want custom behaviour, use a delegating wrapper.
>

Hmm, OK. Could you give some pointers as to what you mean? A brief
google indicates the term "delegating wrapper" is most common in a C#
context. I didn't find much useful related to Python. Despite having
read "How to Think Like a Computer Scientist", I'm afraid I still
think mostly like a plain old scientist.

>> Are there any plans to give a fully OO interface to PIL in the future?
>
> fully OO ?  spent too much in Java land lately ?
>

LOL. Not exactly - virtually all of what little I know about OO comes
from reading python documentation and sources. I've mainly been using
the PyX graphics package up to now, which is pretty
straight-down-the-line OO. I initially found PIL a bit confusing since
sometimes you have to use a function and sometimes a method, and it
was never too obvious which (at least to me). Maybe this is a cunning
plan to force us to actually read the documentation :)

Please don't take any of this as a criticism of PIL. I am sure you
have good reasons for the design you have chosen and I greatly
appreciate all the work you have put into this package, which has been
very useful to me.

Best Wishes

Will

--

  Dr William Henney, Centro de Radioastronomía y Astrofísica,
  Universidad Nacional Autónoma de México, Campus Morelia



More information about the Image-SIG mailing list