[Tutor] Extending Library

Daniel Ehrenberg littledanehren at yahoo.com
Thu Dec 11 17:14:14 EST 2003


Joshua French wrote:
> I want to extend the telnetlib, and essentially
> rewrite interact().  Is
> there a clean/modular way to do this, or would it be
> easier to just
> recreate it, and modify it for my own purposes?
> 
> Thanks,
> -Josh

Telnetlib is written in pure Python, so you could
always just edit it, but you probably don't want to do
that. You should probably instead just subclass the
Telnet class instead. Assuming you don't use any of
the constants defined in telnetlib, your module could
look something like this:

from telnetlib import Telnet as dumbtelnet

class Telnet(dumbtelnet):
    def interact(self):
        print "This is where your code goes"

but if you use the constants, you should probably just
do from telnetlib import *.

Daniel Ehrenberg

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/



More information about the Tutor mailing list