Alex Martelli wrote: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: >>And now, at long last, the image object actually is an image. So why make >>this a two step process? Whatever the Image() initialization does, why >>can't it be done automatically when you read the file? > > "Two-step construct" ("2SC") is a reasonably well-known and widely > useful idiom, and it can serve several kinds of purposes, many but not > all of which are tied to persistence.
I've seen it used as a C++ coding standard when e.g. loading instances from databases (Person p=Person(); p.init(id);) since it was considered bad to have code in the constructor which could throw exceptions. If you make a new Person on the heap, and catch an exception from the constructor, are you sure that you delete the object? -- http://mail.python.org/mailman/listinfo/python-list