Results 1 to 5 of 5

Thread: Python: Twisted

  1. #1

    Post Python: Twisted

    A-hoy hoy!

    Basically I need to be able to use the sendLine() function when the definition is not under a LineReceiver class. Here's an example of what I mean.

    Code:
    def custom():
        self.sendLine('text')
    
    class EchoClient(LineReceiver):
      def connectionMade(self):
         custom()
    But of course that won't work because sendLine is not under the Class EchoClient bit, How could I make this work?

    Thanks Bye!

  2. #2
    Join Date
    Aug 2007
    Beans
    949

    Re: Python: Twisted

    PHP Code:
    def custom(obj):
        
    obj.sendLine('text')

    class 
    EchoClient(LineReceiver):
      
    def connectionMade(self):
         
    custom(self
    Hooray object references?

  3. #3

    Re: Python: Twisted

    Quote Originally Posted by soltanis View Post
    PHP Code:
    def custom(obj):
        
    obj.sendLine('text')

    class 
    EchoClient(LineReceiver):
      
    def connectionMade(self):
         
    custom(self
    Hooray object references?
    That works however if the sendLine is in a while loop, For some reason it won't send any text.

  4. #4
    Join Date
    Aug 2007
    Beans
    949

    Re: Python: Twisted

    Might be buffering or could be a code error. Can I see the relevant loop?

  5. #5
    -grubby is offline May the Ubuntu Be With You!
    Join Date
    Aug 2007
    Beans
    Hidden!

    Re: Python: Twisted

    If you need to share instance variables with that function it should probably be under the class definition. As demonstrated above you can also pass the class instance (self) to the function.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •