OOP / language design question
Duncan Booth
duncan.booth at invalid.invalid
Wed Apr 26 06:22:28 EDT 2006
bruno at modulix wrote:
> It's *already* split : __new__ construct the object, __init__
> initialize it.
>
>> That's why I would go for the 2-phase construction:
>
> But that's already what you have.
Very good point.
>> after the first phase
>> you have an object which is fully initialised, just not yet
>> used/connected/running. For example httplib.HTTPConnection does this:
>> you construct the object with a host and port, but the actual
>> connection is triggered by a separate object.
>
> If you look at file objects, they do try and open the file at init
> time. Is a net or db connection that different ?
Well, yes, since the whole point is that we are discussing overriding
methods and I bet you haven't subclassed Python file objects recently.
For network or database connections you do want to supply your own
handlers for things like authentication.
More information about the Python-list
mailing list