> > > 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. >
>From all the enlightening replies it seems to me that my next task should be to look into what 'factory functions' are. Whenever I've seen the word 'factory' I just skipped it, knowing that if I really need to know what it is, I'll come back to it later. Apparently it's just about time, thanks all for the comments. -- http://mail.python.org/mailman/listinfo/python-list