Re: Strange effect with import

2012-12-21 Thread Jens Thoms Toerring
Hans Mulder han...@xs4all.nl wrote: 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)

Strange effect with import

2012-12-20 Thread Jens Thoms Toerring
Hi, I hope that this isn't a stupid question, asked already a hundred times, but I haven't found anything definitive on the problem I got bitten by. I have two Python files like this: S1.py -- import random import S2 class R( object ) : r = random.random( ) if __name__ ==

Re: Strange effect with import

2012-12-20 Thread Dave Angel
On 12/20/2012 03:39 PM, Jens Thoms Toerring wrote: Hi, I hope that this isn't a stupid question, asked already a hundred times, but I haven't found anything definitive on the problem I got bitten by. I have two Python files like this: S1.py -- import random import S2

Re: Strange effect with import

2012-12-20 Thread Peter Otten
Jens Thoms Toerring wrote: Hi, I hope that this isn't a stupid question, asked already a hundred times, but I haven't found anything definitive on the problem I got bitten by. I have two Python files like this: S1.py -- import random import S2 class R( object ) :

Re: Strange effect with import

2012-12-20 Thread Steven D'Aprano
On Thu, 20 Dec 2012 20:39:19 +, Jens Thoms Toerring wrote: Hi, I hope that this isn't a stupid question, asked already a hundred times, but I haven't found anything definitive on the problem I got bitten by. I have two Python files like this: S1.py -- import random

Re: Strange effect with import

2012-12-20 Thread Jens Thoms Toerring
Thanks a lot to all three of you: that helped me understand the errors of my ways! You just saved me a few more hours of head-scratching;-) A few replies to the questions and comments by Steven: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Thu, 20 Dec 2012 20:39:19 +, Jens

Re: Strange effect with import

2012-12-20 Thread Terry Reedy
On 12/20/2012 5:52 PM, Jens Thoms Toerring wrote: You are rather likely right and I probably should have written: I don't see any way to pass that variable to the object that is supposed to use it. Perhaps you have an idea how it could be done correctly when I explain the complete picture: I'm

Re: Strange effect with import

2012-12-20 Thread Hans Mulder
On 20/12/12 23:52:24, Jens Thoms Toerring wrote: I'm writing a TCP server, based on SocketServer: server = SocketServer.TCPServer((192.168.1.10, 12345), ReqHandler) where ReqHandler is the name of a class derived from SocketServer.BaseRequestHandler class

Re: Strange effect with import

2012-12-20 Thread Jens Thoms Toerring
Terry Reedy tjre...@udel.edu wrote: server = SocketServer.TCPServer((192.168.1.10, 12345), ReqHandler) where ReqHandler is the name of a class derived from SocketServer.BaseRequestHandler You misunderstood the doc. You pass the class, not the name of the class. From 21.19.4.1.

Re: Strange effect with import

2012-12-20 Thread Jens Thoms Toerring
Hans Mulder han...@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