Daniel Nogradi wrote:
> >
> > In this case, Image seems to be a python module, with the open function
> > defined, PIL's Image is not a class.
> >
>
> Thanks for the enlightening remarks, especially this last one, indeed,
> it's not a class.

Actually, this way of creating a class instance is good OO practice in
many places: The Image.open() method acts as a factory-function for
creating Image objects.
You don't know, until you inspect the return value, if the created
object is actually an instance of class Image or something which just
happens to behave like one...
It could for instance be a sub-class of Image, JpegImage, if that
better suits the class library designers.
In general, factory-functions allow greater uncoupling between
interface and implementation.

Regards,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to