[Twisted-Python] Avoid circullair dependencies.

Jaime Wyant programmer.py at gmail.com
Mon Jul 2 12:49:50 EDT 2007

Sounds like you could use a lazy import.  I do something similar to this in
my factory:

# protocol.py
class MyProtocol(XmlStream):

class MyFactory:
    def buildProtocol(self, addr):
        myProtocol = MyProtocol()

        # heres the lazy import
        from othermodule import SomeKlass

My `othermodule' imports some constants from `protocol' (module defined
above).  So, to kill the circular references, I do a lazy import in


On 7/1/07, Ivanov Maxim <redbaron at hitv.ru> wrote:
> Some of my logic need protocol to be imoported to be able to send data
> back.
> So when I start app protocol imports my logic (where all data is
> processed)
> and my logic imports protocol.  Right now I simply pass protocol object as
> argument to constructors, but it seems to be not the best way from my
> point
> of view. How to solve this problem?
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

"Government does not solve problems; it subsidizes them."
Ronald Reagan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20070702/b8fa36b4/attachment.htm 

More information about the Twisted-Python mailing list