<html><body>On 08:42 am, sven-erik.tiberg@ltu.se wrote:<br /><br />>Don't know how to access objects from the main module in the classes in<br />>the lib module.<br />>The tricky part as I see it are ( part of from transive_UDP.py ):<br />># ------------------------------------------------------------------<br />> def datagramRecived(self, data):<br />>        count = 0<br />>        data_str = string.split(data)<br />>        for recive_items in data_str:<br />>            __main__.recived_data[ count ] = float( recive_items )<br />>            count = count +1<br />>        __main__.update_on_recive()<br />><br />>#-----------------------------------------------------------------<br />>The problems are that I need to update __main__.recive.dada before<br />>calling __main__.updat_on_recive().<br /><br />There is no Twisted API or special technique that you need to use.  Just create your objects with references to all the objects they need to manipulate.<br /><br />For example, in main.py, instead of:<br /><br />    reactor.listenUDP(self.port, transive_udp('...',2345, 0.05 ))<br /><br />just do:<br /><br />    reactor.listenUDP(self.port, transive_udp('...', 2345, 0.05, recive_data))<br /><br />and then add an argument to transive_udp's constructor to refer to the data.<br /><br />>Second how to access the  .send_UDP from the __main__ module.<br /><br />Similarly, you can keep a reference to transive_udp object in the main module.<br /><br />I might be able to comment more except the attached example is full of errors and will not even import.<br /></body></html>