Strange effect with import

Jens Thoms Toerring jt at
Fri Dec 21 02:25:57 CET 2012

Hans Mulder <hansmu at> wrote:
> What happens if instead of a class you pass a function that
> takes the same arguments as the SocketServer.BaseRequestHandler
> constructor and returns a new instance of your ReqHandler?

> That's not quite what the documentaion clls for, but I'd hope
> it's close enough.

Interesting idea - I'm not yet at a level of Python wizardry
that I would dare to do something that's not explicitely bles-
sed be the documentation;-) 

> Maybe something like this:

> class ReqHandler(SocketServer.BaseRequestHandler):
>     def __init__(self, request, client_address, server, ham, spam)
>         super(SocketServer, self).__init__(
>                             self, request, client_address, server)
>         self.ham = ham
>         self.spam = spam
>         ....

> And later:

> import functools

> server = SocketServer.TCPServer((, 12345),
>            functools.partial(ReqHandler, ham="hello", spam=42))

Ok, that's still way over may head at the moment;-) I will hhave
to read up on functools tomorrow, it's the first time I heard of
it but it looks quite interesting at a first glance.

Thank you for these ideas, I'll need a bit of time to figure out
these new concepts and I don't think I'm up to it tonight any-
                         Best regards. Jens    
  \   Jens Thoms Toerring  ___      jt at

More information about the Python-list mailing list