Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35253
| From | jt@toerring.de (Jens Thoms Toerring) |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Strange effect with import |
| Date | 2012-12-21 01:25 +0000 |
| Organization | Freie Universitaet Berlin |
| Message-ID | <ajhs55Fht4dU2@mid.uni-berlin.de> (permalink) |
| References | <ajhbbnFe4q1U1@mid.uni-berlin.de> <50d38d78$0$29967$c3e8da3$5496439d@news.astraweb.com> <ajhj58Ffv64U1@mid.uni-berlin.de> <50d3b34e$0$6889$e4fe514c@news2.news.xs4all.nl> |
Hans Mulder <hansmu@xs4all.nl> 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((192.168.1.10, 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-
more;-)
Best regards. Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Strange effect with import jt@toerring.de (Jens Thoms Toerring) - 2012-12-20 20:39 +0000
Re: Strange effect with import Dave Angel <d@davea.name> - 2012-12-20 15:59 -0500
Re: Strange effect with import Peter Otten <__peter__@web.de> - 2012-12-20 22:11 +0100
Re: Strange effect with import Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-20 22:13 +0000
Re: Strange effect with import jt@toerring.de (Jens Thoms Toerring) - 2012-12-20 22:52 +0000
Re: Strange effect with import Terry Reedy <tjreedy@udel.edu> - 2012-12-20 19:54 -0500
Re: Strange effect with import jt@toerring.de (Jens Thoms Toerring) - 2012-12-21 01:12 +0000
Re: Strange effect with import Hans Mulder <hansmu@xs4all.nl> - 2012-12-21 01:54 +0100
Re: Strange effect with import jt@toerring.de (Jens Thoms Toerring) - 2012-12-21 01:25 +0000
Re: Strange effect with import jt@toerring.de (Jens Thoms Toerring) - 2012-12-21 15:52 +0000
csiph-web