a couple IDLE questions

Skip Montanaro skip at mojam.com
Thu Sep 9 10:11:33 EDT 1999


    Guido> Of course, the simpler solution is for you to rename .pythonrc to
    Guido> .pythonrc.py!

Will do.  Still, it would be nice if there was a menu button that said in
effect, "pretend this file contains Python code".  It would then colorize
the contents and do whatever else it does when visiting a Python file as
opposed to a plain text file.

    Guido> Actually, the class browser doesn't care which language your file
    Guido> thinks it is in.  I'd like to see your .pythonrc so I can reproduce
    Guido> why pyclbr.py crashes on it.

That's easy:

    try:
        import addpath
    except ImportError:
        print "failed to import addpath!"

    try:
        import rlcompleter, readline
        readline.parse_and_bind("tab: complete")
    except ImportError:
        pass

    try:
        import xmlrpclib
        index = xmlrpclib.Server("http://index.sony.es.uswebcks.com:5007")
        orca = xmlrpclib.Server("http://www.musi-cal.com:5007")
        dolphin = xmlrpclib.Server("http://dolphin.mojam.com:5007")
        mission = xmlrpclib.Server("http://mission.mojam.com:5007")
    except:
        print "failed to define server objects!"
        index = orca = dolphin = mission = None

    try:
        import pprint, __builtin__
        class Writer:
            def __init__(self):
                self.pp = pprint.PrettyPrinter()

            def repr(self, obj):
                return self.pp.pformat(obj)

            str = repr

        __builtin__.repr = Writer().repr
        __builtin__.str = Writer().str

    except ImportError:
        print "failed to define alternate repr()!"

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098   | Python: Programming the way Guido indented...




More information about the Python-list mailing list