[EMAIL PROTECTED] a écrit : > i wish to have some extended functionality added to sockets > > i can create my own socket class class mysocket(socket.socket): > > and all should be fine. Except, the sockets are created for me by the > accept method, listening on port. So how can i take the standard > socket created for me and create a 'mysocket'. I need a method that > will initialise any new properties i have added in my class, but how > can i change the class of the socket created?
object.__class__ = OtherClass But this may not be the wisest solution. What you want is not inheritance, it's decoration (AKA wrapping). IOW : instead of directly using accept(), use a wrapper around it that will returns socket objects wrapped in your own class. My 2 cents... -- http://mail.python.org/mailman/listinfo/python-list